由买买提看人间百态

topics

全部话题 - 话题: except
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
i****e
发帖数: 913
1
Spring's use of unchecked data access exceptions is consistent with that of
many - probably most - successful persistence frameworks. (Indeed, it was
partly inspired by JDO.) JDBC is one of the few data access APIs to use
checked exceptions. TopLink and JDO, for example, use unchecked exceptions
exclusively. Hibernate switched from checked to unchecked exceptions in
version 3.
这是Rod讲解Spring JDBC的原话
http://www.theserverside.com/news/1364527/Introduction-to-the-S
大体意思是:
By wrapping JDBC check exce... 阅读全帖
f*******d
发帖数: 637
2
来自主题: Olympics版 - Truly exceptional到底啥意思啊
exceptional |ikˈsepSHənəl|
adjective
unusual; not typical: crimes of exceptional callousness and cruelty.
• unusually good; outstanding: a pepper offering exceptional flavor
and juiciness.
• (of a child) mentally or physically disabled so as to require
special schooling: helping parents of exceptional children.
exceptional
adjective
1 unusually good:
At the age of five he showed exceptional talent as a musician. * The quality
of the recording is quite exceptional.
... 阅读全帖
s*******g
发帖数: 1514
3
☆─────────────────────────────────────☆
AprilSummer (人生如梦,一尊还酹江月) 于 (Wed Oct 13 14:51:57 2010, 美东) 提到:
The short answer to this question is "No as long as you have an advance
degree."
之前在版上看到有人问NIW如何证明Exceptional ability,实际上,除非你没有硕士学
位,否则不要去展开论述证明Exceptional Ability。如果你能满足Exceptional
Ability规定的六条自然好,当然也要放进petition letter中,但论述写作过程中,只
要说明申请人有advance degree就好了,不用专门提出証明申请人有exceptional
ability。
如果没有硕士以上学位,你就必须要证明你有Exceptional Ability。
☆─────────────────────────────────────☆
banCDM (蚂蚁) 于 (We... 阅读全帖
g****y
发帖数: 15
4
来自主题: Java版 - 关于Exception,Catch
呵呵,那天没仔细看。
把没处理的exception都wrap成MyLibException,好像有问题,使用这个method的代码不
知道当MyLibException发生时,究竟是什么具体的exception。当然你在外面的代码里面
可以用myLibExceptin.getOriginalException()得到具体是什么exception,但编译器并
不会强制用户一定要处理这个exception,所以很有可能一些exception本来应该被处理的
,但用户忘了处理。这也是为什么declare method时强调要throw具体的exception class
,而不是throw一个throwable或exception。
exception handler的那个用法是可以的,是dependency injection的一个应用。但它同
样有上面说的那个问题。
用AOP的方法处理exception,也有同样的问题,看到的那些讨论认为这是一个缺陷。
i****e
发帖数: 913
5
另外这是有关unchecked/checked exception的讨论
http://www.javapractices.com/topic/TopicAction.do?Id=129
unchecked ex = unrecoverable, for example NPE, IAE
checked ex = recoverable, representing invalid conditions in areas outside
the immediate control of the program (invalid user input, database problems,
network outages, absent files)
(here, database problem is considered as outside of main program logic)
所以Sun的人认为JDBC是side logic, JDBC layer出问题了, main Java program是
recoverable的, 所以就把JDBC搞成checked excepti... 阅读全帖
b***i
发帖数: 3043
6
就是那个JBoss Spring Framework终于可以使用Mysql了。但是,每次我手动重启后,
打开页面就出现Exception。为什么刚开机就不能open database?是不是那个database
。我经常需要等待一小时以上才能看到正常的网页。此app使用了Hibernate。我就是想
看到一个网站能够把用户保存的数据存到数据库,下次app重启后仍然可以看到保存过
的数据。我手动重启是为了模拟网站计算机崩溃,然后看看数据库是不是还在。为什么
这么个简单的事情就这么多问题?
org.springframework.web.util.NestedServletException: Request processing
failed; nested exception is javax.persistence.PersistenceException: org.
hibernate.exception.JDBCConnectionException: could not prepare statement
javax.persistence.PersistenceExcepti... 阅读全帖
R***r
发帖数: 120
7
来自主题: JobHunting版 - 请教个java exception的问题
try
{
...
throw new Exception(1);
}
catch (Exception ex)
{
...
throw new Exception(2);
}
finally
{
...
throw new Exception(3);
}
最后返回的是finally里的Exception(3),请问catch里的Exception(2)到哪里去了?直
接garbage collection了?
L*******r
发帖数: 1011
8
typically I only use exceptions for rare happened errors.
Althrough MS said using exceptions would not bring too much performance penalty,
I doubt it. Java will have performance penalty when using exceptions especially
for JIT VMs. You can find infromation from IBM.
If the error is really a "wrong opertions", just use exceptions for good code
management. But don't abuse exceptions. I have seen some guy used exceptions
for the situation that would happen > 20% probability. That's really not
excep
c*****t
发帖数: 1879
9
来自主题: Programming版 - 大家对 exception 都是怎么处理的?
得看是什么 exception,同时该 exception 是否 violate 执行该 function
的 assumption 。
比如,某 function 的 assumption 是出问题 throw A。但是该 function
又执行其他 function (可能会出现 B exception)。这时候你得将所有
非 A 的 exception 给 catch 了,然后 wrap 到 A 里面(或者提供正确
的错误信息)。否则,很可能造成非常奇怪的 bug 。如果用的语言提供
checked + unchecked exception,要非常注意两个 exception 都得给
catch 住(以前碰到过别人的 code 里的这种 bug)。
有些情况是,该 function 明确的 assume 可能会出现 A,但是也可能会
有 B。这种情况下,该 function 可以不 catch B 。
p*******m
发帖数: 136
10
来自主题: Olympics版 - exceptional被翻译成了无以伦比
反正不是无以伦比的那个意思。准确的翻译大概就是 非 常。
exceptional
One entry found.
exceptional

Main Entry: ex·cep·tion·al
Pronunciation: \ik-ˈsep-shnəl, -shə-nəl\
Function: adjective
Date: 1787
1: forming an exception : rare
2: better than average : superior
3: deviating from the norm: as a: having above or below average intelligence
b: physically disabled
— ex·cep·tion·al·i·ty \-ˌsep-shə-ˈna-lə-tē\ noun
— ex·cep·tion
d*****t
发帖数: 7903
11
来自主题: Olympics版 - exceptional被翻译成了无以伦比
exceptional
ex·cep·tion·al /ɪkˈsepʃənəl/ adj
1) unusually good
= outstanding
Richard is an exceptional student.
exceptional bravery
2) unusual and likely not to happen often
This is an exceptional case; I've never seen anything like it before.
Promotion in the first year is only given in exceptional circumstances .
g****n
发帖数: 3313
12
闭幕式上罗格并没说无与伦比 ,truly exceptional 不等于无与伦比 <空> --- Ruofei
Aug 26, 08:38, 2008 [ 0 bytes ]
* 写推荐信时,exceptional是最高一挡。就是top 1%, 下来才识outstanding. <
空> --- bbsm Aug 26, 09:31, 2008 [ 0 bytes ]
o 办绿卡时第一档EB1是extrodinary, 第二档EB2是outstanding/
exceptional <空> --- f-000 Aug 26, 09:41, 2008 [ 0 bytes ]
+ 他是美国移民局派来的?整这些没什么意思 <空> --- null2k Aug
26, 10:57, 2008 [ 0 bytes ]
* exceptional=出众;truly exceptional=出类拔萃 <空> --- f-000 Aug 26, 09
o 无与伦比还是比出类拔萃高吧? <空> --- Ruof
M********5
发帖数: 715
13
来自主题: JobHunting版 - 一个c++题(exception handling)
呵呵,我觉得这个rule是没有问题的
我的理解,只要throw的exception是父类exception的子集就行了,它并不提供类型转
换的(所以short当然不能算int),你上面举的例子,throw三个int的exception,那也
是int的exception,而不是short的exception,个数跟类别是两个不同的概念
这是我的理解
A*********r
发帖数: 8271
14
来自主题: Immigration版 - NIW需要证明Exceptional Ability么?
The short answer to this question is "No as long as you have an advance
degree."
之前在版上看到有人问NIW如何证明Exceptional ability,实际上,除非你没有硕士学
位,否则不要去展开论述证明Exceptional Ability。如果你能满足Exceptional
Ability规定的六条自然好,当然也要放进petition letter中,但论述写作过程中,只
要说明申请人有advance degree就好了,不用专门提出証明申请人有exceptional
ability。
如果没有硕士以上学位,你就必须要证明你有Exceptional Ability。

发帖数: 1
15
File NIW, 需要出示关于 Professional Membership的证据吗?
好像如果 file EB2 for Exceptional Ability, the initial evidence must include
at least 3 of the 6 types of evidence listed below. 但是 file NIW 无此要求(
i.e.,至少6条中满足3条)?NIW 不是也属于EB2,算不算EB2 for Exceptional Ability
中的一种?I am confused.
1) Have you received a degree, diploma, certificate or similar award
from a college, university, school or other institution, relating to the
field of exceptional ability?
2) Do you have at least ten years of full-time expe... 阅读全帖
c*****t
发帖数: 1879
16
来自主题: Java版 - 关于Exception,Catch
我 subclass MyLibException 其实和在 MyLibException 里加个 flag 一回
事,不过在不同 function 里 throw 不同的 subclass 的 MyLibException
就比较直观点。
至于为什么要 catch 一部分,不 catch 另一部分,是因为如果我在叫
ExceptionHandler 的 handleException (ex) 时,如果 ExceptionHandler
觉得该 Exception 可以被 Ignore,那么就把这个 ex 给吃掉。如果 ex
是 fatal error ,那么就会将其再 re-throw 。因为我的 code 把所有
非 MyLibException 的 exception 都网住,那么也就是说出现的
MyLibException 肯定就是说该 exception 已经被 ExceptionHandler 处理
过了,所以一定不能给其再套一个 MyLibException。
一个 exception 套另外一个 exception 很常见。比如 SQLException 就
套装 P
g****y
发帖数: 15
17
来自主题: Java版 - 关于Exception,Catch
1.
catch (MyLibException ex)
{
throw ex;
}
是没意义的,catch不做任何处理有抛出还不如就把这几行去掉。
2. 那个exception handler只在当exception处理很简单时才有用,这样的design是有些
问题的,因为很多时候,一个method declare时希望明确指定具体的exception类,抛出
MyLibException和抛出Exception或Throwable并没有本质区别,都是generic exception
i****e
发帖数: 913
18
RuntimeException是Exception的subclass, 可以catch,可以rethrow, 也可以
specify/declare在method的delaration上(注意楼主在这里有点概念不清, throws
exception不是signature的一部分, 只是告诉compiler如果是checked exception,
compile时候帮忙check一下; 还有就是subclass的overiding method只能throws同样或
inherited checked exceptions).
Spring JDBC/TopLink/JDO/H8既然跟JDBC反着干, 理应specify all their unchecked
exceptions on method declaration, 其实Spring JDBCTemplate也是这样做了.
http://static.springsource.org/spring/docs/2.0.x/api/org/spring
而且由于是throws RuntimeException, 不catch... 阅读全帖
r*********r
发帖数: 3195
19
来自主题: Programming版 - 关于 exception 的一个问题
中定义了 class exception:
class exception
{
public:
exception() throw() { }
virtual ~exception() throw();
virtual const char* what() const throw();
};
问题: 为什么 what() 返回一个 const char * 类型?
为什么不返回一个 string 呢? 可以返回一个 string 吗?
g*****g
发帖数: 34805
20
来自主题: Programming版 - 一道编程题 - throw Exceptions
You throw exception whenever it's exceptional conditions.
Negative size is exceptional, improper configuration is exceptional
too. Exception gives caller a chance to handle the error. The processing
can be as simple as log and ignore, but should be throwed as long as the
callee cannot handle it.
t****t
发帖数: 6806
21
来自主题: Programming版 - C++的exception大家常用吗?
你觉得别扭可能是因为你没有按照C++的风格来写程序. 如果你把C++作为一个C
superset来用, 那exception肯定不好用. 但是按照C++的风格, 把错误和正常返回的
path分开是很方便的. 随便举几个例子:
* 你可以在constructor里扔出异常. 部分分配的对象会被自动释放. error code不行.
* 你可以在overloaded operator里扔出异常. error code不行. 推广: 在你不能改变
function signature的时候, 异常很方便.
* 你不需要在每个叶子调用检查返回值. 可以在调用树较高的地方, 或者说方便报告出
错的地方, 接住异常并报告. 更重要的是, 你也不会忘记检查返回值. 比如说你不需要
在每个new检查是否返回0(事实上正常的new并不返回0, 除非你使用nothrow调用).
你需要做的:
* 除非你准备出错后立刻退出, 否则所有动态分配的内存和其它资源(file handle,
socket, sync lock, etc)必需能够自动释放. 你需要使用容器(STL container),
smart... 阅读全帖
d****t
发帖数: 65
22
<--- 朗道英汉字典5.0 --->
exceptional
*[ik'sep??n?l]
a. 例外的, 异常的, 特别的
<--- 牛津现代英汉双解词典 --->
exceptional
/?k?sep??nl; ?k?s?p??nl/ adj very unusual; outstanding 异常的; 罕见的; 特殊
的; 杰出的; 突出的: This weather is exceptional for June. 这种天气在六月份很
罕见. * show exceptional musical ability 表现出非凡的音乐才能.
A*T
发帖数: 4820
23
With Yao Ming out for the season, the Houston Rockets are requesting a
disabled player exception that would allow them to bring in another player,
the Houston
Chronicle reports.
The exception would allow the Rockets to trade for a player without matching
salaries, but only up to the mid-level exception amount of $5.7 million.
Theoretically that money could be used to sign a free agent, too, but there
is
nobody on the market worth near that amount or that the Rockets really have
interest in acqui... 阅读全帖
b***i
发帖数: 3043
24
程序用了Swing, 然后用了Nimbus主题,主窗口是一个JTextPane,利用一个Task每60毫
秒绘制背景,每次大约需要15毫秒。
中间有一次需要把Frame setVisible(false),setResizable等,然后重新显现窗口。出
现本文中最后出现的Exception。如果把task改成每15毫秒一次,则每次都可以出现这
个Exception.用的是jdk。如果改为jre,则看到Exception次数变少,内容都一样,没
有行号。
会是什么原因?会和Repaint以及窗口短暂消失有关系吗?窗口消失的时候,里面有加
入一些Swing的元件,比如layered Pane等。
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.
lang.Boolean cannot be cast to com.sun.java.swing.Painter
at com.sun.java.swing.plaf.nimbus.NimbusStyle.getBackgroundPai... 阅读全帖
yy
发帖数: 45
25
来自主题: Programming版 - c++ exception 一问
suppose I have a statement like:
throw;
(throw without a type exception)
Can I know what is the default exception for c++?
It seems to me: if there is no outer layer exception, statement
throw ;
will return a notype exception and cause Abort anyway even if
I use
catch (...)
Any idea, thanks,
r*********r
发帖数: 3195
26
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
i think exception has a more damaging problem.
that is, it will cause memory leak, when the exceptional path is taken.
especially when exceptions are thrown from constructors and destructors.
using RAII may solve the problem if the exception is thrown by constructor.
but the ones thrown by destructors are truly problematic.
g*****y
发帖数: 7271
27
来自主题: Programming版 - 有大侠讲讲RTTI和exception的问题么?
I actually quite disagree this opinion. When discussing the good/bad of
exception. You have to think about when you should use it? If it is not good
, what are the alternatives? Do the alternatives solve the problem of
exception?
You should use exception when you have errors that cause the function cannot
finish its task. For example, you cannot get the memory you need from new/
malloc. If you do not use exception, you usually return error code. You
still have different excution path for errors
t****t
发帖数: 6806
28
来自主题: Programming版 - A C++ exception question
fopen() is from libc, it doesn't throw any exception. if open fails, it
returns NULL.
on the other hand, if an exception is thrown (whatever reason) and is not
catched by catch block, terminate() will be called, which will in turn call
terminate handler set by set_terminate(). the default handler will call
abort().
if an exception is thrown and is not listed in exception-specification,
unexpected() will be called, which will in turn call unexpected handler set
by set_unexpected(). the default ha
p***o
发帖数: 1252
29
来自主题: Programming版 - Exception
你这不是都知道么 ...
用exception把处理错误代码和正常流程分开。exception确实是强制处理的,只不过
不一定要在caller处理,你不处理程序直接退出。抛exception的地方和处理exception
地方之间靠finally或者stack unwinding清理资源。当然很多时候finally也不方便,
你看C#和Java或早或迟也加入了类似stack unwinding的try with。
p***o
发帖数: 1252
30
来自主题: Programming版 - Exception
你这不是都知道么 ...
用exception把处理错误代码和正常流程分开。exception确实是强制处理的,只不过
不一定要在caller处理,你不处理程序直接退出。抛exception的地方和处理exception
地方之间靠finally或者stack unwinding清理资源。当然很多时候finally也不方便,
你看C#和Java或早或迟也加入了类似stack unwinding的try with。
b***y
发帖数: 14281
31
exceptional: 1. Being an exception; uncommon. 2. Well above average;
extraordinary
傑:本意高傲,[说文]解释是“特立也”,才华出众才是引申意义。
出:不用解释了吧,当然就是out of normal,uncommon的意思。
所以说exceptional=杰出 是直接了当最恰当不过的翻译。
y****g
发帖数: 36950
32

呵呵,你不是文盲,但可以判断出你是个智商不高,研究能力不强的照本宣科的书呆子。
1.这个牌子英文翻译叫EXCEPTION,不是EXCEPTIONAL
2.这个设计师是中国人,她就是起名中文<例外>,例外这个名字明显是要反应设计师特
立独行与众不同的设计观点。然后翻译成英文EXCEPTION。
搞不懂你在啰嗦什么?难道习近平中文姓Xi,你硬要说英文应该是She,是她的意思
,然后把习近平改成"她近平"?
e********g
发帖数: 112
33
来自主题: Olympics版 - Truly exceptional Games?
1. 你显然不知道exceptional比outstanding, excellent都更好.
2. 你显然不知道unprecidented可以是褒义的可以是贬义的. 而exceptional
只有褒义. 而按照西方表扬一方但不能贬低别人的说话方式, 是不合适
以奥委会的身份夸奖北京unmatched, 这样是会犯政治性错误的.
Rogge的本意,就是夸奖北京奥运无与伦比. 虽然字面上exceptional跟中文的
无与伦比表达的意思有一些差别.

first
.
We
k****k
发帖数: 3322
34
没人否认美国是个很不错的国家:地大物博,环境保护得好,人民比较富裕,政治比较
开明自由。但世界上那么多国家,没有哪个国家像美国的政客那样时时把自己的国家吹
嘘得一塌糊涂,让人起一身鸡皮疙瘩。
这不,奥巴马总统在星期二的全国演讲中,说到为什么要攻击叙利亚,竟然说其中的一
个原因是 “because we are America, and America is exceptional!”. 他的这些
话,不知美国人听了作何感想,但我相信很多其他国家的人听了只会摇头。且不说这句
话有歧视他国国民的嫌疑,美国人,美国总统如此自大,如此目中无人,叫世界人民如
何信服?
问题是,美国人真的就那么“exceptional”, 可以看到别人看不到的,做别人不能做
的,与世界人民不一样吗?我想不是吧。在美国暴饮暴食,胖得像猪一般的人比任何国
家都多;在美国对世界一无所知,却总认为老子天下第一的人大有人在;在美国想着法
的不干活,挖空心思领福利的人到处都是;美国人口只占世界的5%,却关着超过百分之
十几的罪犯…..美国人,不说和发展中国家比,好像和很多发达国家都差不多吧。
两百多年前,美国诞生了。与很多... 阅读全帖
c**********e
发帖数: 2007
35
来自主题: JobHunting版 - C++ Q50: exception derivation (C5)
In a class inherits from another and overides a virtual function, how must
the exception-specification for the derived (overridden) function be related
to the base function?
a) Derived functions cannot have exception specification.
b) It must be at least as restrictive.
c) It must be the same.
d) Virtual functions cannot have exception-specifications.
e) It must be less restrictive.
t**g
发帖数: 723
36
LD以前做TB test,20mm,反应比较厉害,医生还注明“advised to not have future
PPD skin tests"。 再做估计胳膊就变大力水手了。所以这次他就直接X-ray了,没有
做TB。
照一些人的说法,没做TB要被RFE。
不过USCIS网站上有这么一段:
Q. Are there any exceptions to the initial TB testing requirement?
A. Yes. Under the May 2008 TB Component of the Technical Instructions for
the Medical Examination of Aliens in the United States, and its update, an
applicant may not be required to undergo the initial TB screening testing
with a TST or IGRA under the following circumstances:
(其中一项,就是... 阅读全帖
E***e
发帖数: 3430
37
来自主题: Hardware版 - AMD的APU上跑ArrayFire的exception
试图跑ArrayFire的GPU计算
在另一台机器上CUDA+ArrayFire都能跑
回到家里电脑上的APU+OpenCL+ArrayFire就出现如下问题
Unhandled exception at at 0x000007FEFDAA940D in helloworld_debug.exe:
Microsoft C++ exception: af::exception at memory location 0x000000000025E748.
不是很懂硬件软件什么的
这个是怎么回事?
是不是因为我APU不是专门留出来做计算的?
t*******e
发帖数: 684
38
不适应不代表不好,事实上exception handling是spring里非常有价值的东西,每本
spring的书都会提到。那些jdbc的破checked exceptions,你catch了也没用,什么都
干不了,就应当转成runtime exception。
t*******e
发帖数: 684
39
Why can't you catch the unchecked exceptions? Almost each JDBC exception
type is mapped to a corresponding Spring runtime exception.
P***t
发帖数: 1006
40
来自主题: Programming版 - 为什么用try catch不住exception?
For divide by zero, on Win32 system, there will be an Win32 Exception throwed,
and
it can't be catched by C++ exception handler. However, you can use:
__try
{
...
}
__except( EXCEPTION_EXECUTE_HANDLER )
{
}
with VC to catch Win32 exception. See help of __try.
For the second new stuff, it really depends on the implementation of "new".
But normally you should be able to catch it though. Make the number bigger.
I've tried 0x3ffffff0 and it works for me.
These things are compiler/system
c***d
发帖数: 996
41
来自主题: Programming版 - [合集] Exception Handling in C
☆─────────────────────────────────────☆
baton (rouge) 于 (Mon May 14 21:56:25 2007) 提到:
It seems to me that exception is not used extensively
in C++ system library source code, such as STL.
Is exception handling a feature of little use in C++?
Thanks.
☆─────────────────────────────────────☆
blueivan (bl.ue) 于 (Wed May 16 15:06:08 2007) 提到:
C does not have exceptions. There are some implementations uses goto or setj
mp. Both approaches are limited. If portability is not a problem, use
q*********9
发帖数: 8
42
来自主题: Programming版 - 一道编程题 - throw Exceptions
Exceptions should only be thrown under exceptional conditions, in all the
cases, you can return some error message to indicate error. I don't
understand why we must( or better ) throw exception?
goodbug, would you explain ?
Thanks,
c*****t
发帖数: 1879
43
来自主题: Programming版 - 一道编程题 - throw Exceptions
goodbug's answer is merely for general cases, not for specific senarios.
It is quite annoying to handle a lot of checked exceptions sometimes.
Unchecked exception is dangerous if not handled. Returning error code
is pretty much like checked exception, only worse since one has to check
the error. If you are going to deal with each specific error any ways,
returning error code is better.
So take-n-pick the best thing for you.
z****e
发帖数: 2024
44
来自主题: Programming版 - Two questions about handling exceptions in C++
1. very bad idea. not necessarily to have crash, but very well possible.
reason: when an regular exception is thrown, the destructors for existing
objects are called. if within these destructors, an other exception is
thrown, then the program will terminate immediately. very bad. none of the
exceptions are caught.
2. fine. some additional attention is needed, such like avoid naked pointers
in ctor, etc.
p***o
发帖数: 1252
45
来自主题: Programming版 - C++的exception大家常用吗?
有个东西叫exception-safety,写库卖钱的要考虑一下,一般人写程序就算了吧。
C++ exception最不好的地方就是没有内置的函数显示调用栈。看看java/python
用exception多方便,也没听人抱怨过。
k******r
发帖数: 2300
46
来自主题: Programming版 - C++的exception大家常用吗?
你想过没有,如果没有exception handling 在出现exception的时候会发生什么?程序
立刻结束了。但是有exception handling 程序不会退出,用户看到出错信息,然后可
以选择调整一下,重新作一遍。如果是程序本身的问题,可以报告软件商。
e****d
发帖数: 895
47
来自主题: Programming版 - C++的exception大家常用吗?
I think your question also applies to the exception handling of
other languages. If you are concerned about missing finally statement
or not being able to print out exception stacks, you can solve it by
proper RAII and exception chaining.
b******n
发帖数: 592
48
来自主题: Programming版 - C++的exception大家常用吗?
assert is different than exception. And assert depends on the build, you
only
have it in DEBUG build. when assert fails, the program has to terminate.
Imagine
a library you use has all asserts, no error code. In your case,
assert is a exception you never catch, meaning you can't use that exception
information to recover or do anything.
of course there is a proformance hit. You shouldn't worry about it anyway.
normally it is not an issue to write safer code while losing a little bit
on performanc... 阅读全帖
e******0
发帖数: 211
49
来自主题: Programming版 - 请教一个c++ throw exception 问题
在看c++ faq++,有个问题
faq 31.04
#include
#include
using namespace std;
class X { };
void mayThrow() throw(int)
{ throw 42; }
class Fred {
public:
Fred() throw(bad_alloc, int);
~Fred() throw();
Fred(const Fred& f) throw();
Fred& operator= (const Fred& f) throw();
private:
X* p_;
};
Fred::Fred() throw(bad_alloc, int)
: p_(new X()) { mayThrow(); }
Fred::~Fred() throw()
{ cout << "Not reached #1\n"; delete p_; }
int main()
{
try {
Fred f;
cout << "Not reached #2\n... 阅读全帖
g*****g
发帖数: 34805
50
来自主题: Programming版 - 大家对checked exception怎么看
It's verbose but typically reduces bugs upfront. Many exceptions can be
ignored. Checked exception forces you to make a decision. Without it you may
realize you should catch and ignore an exception after a production bug.

常。
1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)