- 浏览: 389417 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
this is a code that shows how you do the catch all exception handler in C++; it may sound platitude, but C++ lacks of the type system which dictate that all the excpetion should derive from the Exception base class so to catch all exception , no matter which type it is (may it be an primitive type, a string, or an exception derived class or even a custom class) you can catch and handle it also, there is no such finally keyword that can do some resource release work, so it is adviced that you can use the catch all and do the proper deallocation there.
below is the fake/mock code that show an typical resource class.
class resource { public: void lock() ; void releaes(); }; void resource::lock() { } void resource::releaes() { }
and follow is the code that uses the catch all exception handlers as follow.
void catchCallHandler() { resource res; res.lock(); try { // use res // some action that causes an exception to be thrown res.releaes(); } catch (...) // ... the tree dots are refered as the ellipsis, which is quite often used in many a place. { res.releaes(); throw; // and you can rethrow the exception after you do the proper deallocation of the resources // or you can opt not rethrow, but you can just return if the handler have handled the exception safely } res.releaes(); }
however, though we have the way to use the catch all handlers, we have a better way in C++;
though we discussed the catch (...) expression , it is not the only way of recover from the exception site, a better way and a more native way is to use the C++'s resource initialization is the resource aquisition paradigm/paragon. whereas the destructor which exit the function Will take responsibility of cleaning up the resource.
发表评论
-
不安装Visual Studio,只用Windows SDK搭建VC环境
2013-12-31 21:52 15285首先你需要下载的是 Microsoft Windows S ... -
rpath - runtime search path
2013-04-03 11:36 965RPath is a very interesting to ... -
C++ - autogenerated copy constructor and assignment operator gotchas
2013-01-24 13:32 744It has been changed that the s ... -
c++ - rethrow a exception gotchas
2012-12-23 10:57 919As in my prevoius example in j ... -
c++ -typeid operator
2012-10-15 22:30 1032typeid is the one of the meager ... -
c++ - dynamic_cast revisit
2012-10-14 21:21 738There are several built-in type ... -
c++ - virtual inheritance example 1
2012-10-14 15:25 784we have discussed the virtual i ... -
c++ - virtual inheritance
2012-10-12 08:58 914As we have discussed in the pos ... -
c++ type of inheritance
2012-09-28 08:58 722There are 3 types of inheritanc ... -
c++ - vritually virtual new
2012-09-27 23:59 931Let's see what if we want to cl ... -
c++ - virtual destructor
2012-09-27 22:01 924As we all know that virtual des ... -
c++ - vritual function and default arguments
2012-09-27 08:56 951As we all know that we virtual ... -
c++ - template specialization and partial specialization
2012-09-26 22:38 1287in this post, we are going to e ... -
c++ - member template in class template
2012-09-26 08:19 903class member template can be us ... -
c++ template class and the pattern to use its friends
2012-09-25 23:47 958template class may defined thei ... -
c++ - Friend declaration in class Template
2012-09-25 08:47 1182There are three kinds of friend ... -
c++ - class template default parameters
2012-09-25 08:18 804the template has parameter, it ... -
c++ - operator new and delete and an example of linked list stores by new/delete
2012-09-24 07:53 554The operator new and delete ope ... -
c++ - delete(void *, size_t) or delete(void *)
2012-09-24 07:18 1134In my previous dicuss, we have ... -
c++ - placement operator new() and the operator delete()
2012-09-23 15:22 837A class member operator new() c ...
相关推荐
Laravel开发-laravel-jsonaware-exception-handler .zip
Laravel开发-enhanced-exception-handler Laravel的增强异常处理程序
Laravel开发-laravel-jsonaware-exception-handler Laravel JSON感知异常处理程序
git clone https://github.com/master-atul/react-native-exception-handler-example yarn install react-native run-ios --configuration Release或react-native run-android --variant=release 即使在开发模式...
spring-rest-exception-handler, 一个方便的RESTful api Spring MVC 异常 spring REST异常处理程序 这个项目的目的是为for提供一个方便的异常处理程序( 解析器),它满足了错误响应的最佳实践。 处理自定义异常。...
Laravel开发-exception_handler Laravel 5网站的异常处理程序。
React本机异常处理程序 ... 该模块有助于防止RN Apps突然崩溃,而不会向用户显示优美的消息。 在当前情况下: In DEV mode , you get a RED Screen error pointing your errors. In Bundled mode , the app just ...
hive-hbase-handler-1.2.1.jar解决hive1.2.1,hbase不兼容情况!
表达超时处理程序 快速超时中间件,可确保在超时事件时将响应返回给客户端。... npm install --save express-timeout-handler 用法 var timeout = require ( 'express-timeout-handler' ) ; var express = requir
HBase2.1.3整合Hive3.1.2,Hive官方的hive-hbase-handler-3.1.1.jar包不好用,自己编译后的,确认好用
EPSON High Speed IC Handler User Manual。硬件资源介绍,设备设置及使用。通信功能设置方法及信号定义。
hive1.2.2版本和hbase1.0.2的通信包,重新封装的,也进行了相关代码的删除和部分修改
composer require nordsoftware/lumen-chained-exception-handler 用法 将$app->singleton()调用替换为以下内容,该调用将在bootstrap/app.php注册具体异常处理程序: $ app -> instance ( Illuminate \ ...
玩转Android---组件篇---Handler的使用玩转Android---组件篇---Handler的使用玩转Android---组件篇---Handler的使用
idea2019.3使用ecj-4.10.jar 处理bom字符,不用去除文件默认的bom字符,java compiler编译方式更改为eclipse,下面的path to ecj batch compile tool 设置为下载好的资源就可以,考虑了项目整体编码对调用ecj的影响
开源项目-ddo-go-vue-handler.zip,ddo/go-vue-handler v0.0.1 is just released Host Vue app with Router history mode in Golang
Hive-1.2.1与HBase-1.3.1兼容处理的jar包 hive-hbase-handler-1.2.2.jar
sitecore-exception-handler Sitecore异常处理程序模块