Tag: 线程exception

在没有例外的情况下,C ++exception以何种方式减慢代码?

我读过使用C ++exception进行exception处理的开销,而不是检查返回值。 我只是谈论没有抛出exception时发生的开销。 我还假设你需要实现实际检查返回值的代码,并执行相应的操作,无论这些操作与catch块的操作相同。 而且,比较抛出exception对象和内部45个状态variables的代码到每个错误都返回一个负整数的代码也是不公平的。 我并不是试图为C ++exception构build一个案例,而仅仅基于哪一个可能执行得更快。 一旦你考虑了检查返回值和处理错误所需要的所有额外的簿记代码,我最近听说有人提出这样的例子:使用exception的代码应该和基于返回码的代码一样快。 我错过了什么?

当一个exception在multithreadingC ++ 11程序中未处理时会发生什么?

如果我有一个C ++ 11程序运行两个线程,其中一个抛出一个未处理的exception,会发生什么? 整个程序会不会是一场火热的死亡? 请问抛出exception的线程是否会死亡(如果是的话,我能否在这种情况下获得exception)? 还有其他的东西吗?

在pydev中打破例外

是否有可能得到pydevdebugging器打破例外?

“exception已被调用的目标抛出”错误(mscorlib)

我有一个ASP.Net 2.0开发的网站是抛出错误 "Exception has been thrown by the target of an invocation" 在生产环境中。 这不是在开发中抛出这个错误。 来源是'mscorlib',堆栈跟踪表示错误在 System.RuntimeMethodHandle._InvokeMethodFast. 自我上次上传以来,唯一改变的是我已经开始使用Membership控件(Login,LoginView),并增加了一些存储过程和表格等等。成员依赖于一个自定义的提供者,已经写了。 任何人都知道为什么会发生这种情况?

如何find哪些promise在nodejs中未处理UnhandledPromiseRejectionWarning?

从版本7的nodejs有asynchronous等待处理承诺的sintactic糖,在我的apis下面的警告经常出现: (node:11057) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ReferenceError: Error: Can't set headers after they are sent. (node:11057) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 不幸的是,没有提到渔获缺失的地方。 有没有办法find它没有检查每个try catch块?

在Python中禁用断言

如何禁用Python中的断言? 也就是说,如果一个断言失败了,我不希望它抛出一个AssertionError ,而是继续前进。 我怎么做?

.NET:如何将exception转换为string?

当引发exception(在IDE中进行debugging时),我有机会查看exception的详细信息 : 但在代码中,如果我打电话exception.ToString()我不明白这些有用的细节: System.Data.SqlClient.SqlException (0x80131904): Could not find stored procedure 'FetchActiveUsers'. […snip stack trace…] 但是Visual Studio有一些魔力,可以将exception复制到剪贴板 : 这给出了有用的细节: System.Data.SqlClient.SqlException was unhandled by user code Message=Could not find stored procedure 'FetchActiveUsers'. Source=.Net SqlClient Data Provider ErrorCode=-2146232060 Class=16 LineNumber=1 Number=2812 Procedure="" Server=vader State=62 StackTrace: […snip stack trace…] InnerException: 那么我想要的! 什么将是的内容: String ExceptionToString(Exception ex) { //todo: Write useful […]

如何将信息添加到Ruby中的exception消息?

如何将信息添加到exception消息,而不用在ruby中更改它的类? 我目前使用的方法是 strings.each_with_index do |string, i| begin do_risky_operation(string) rescue raise $!.class, "Problem with string number #{i}: #{$!}" end end 理想情况下,我也想保留回溯。 有没有更好的办法?

抑制C#中未使用的exceptionvariables的警告

我有这个代码: try { someMethod(); } catch (XYZException e) { // do something without using e } 这样做会给我一个关于声明的警告,但不会使用我讨厌的e 。 不过,我也不想使用没有这个variables的catch子句,因为那样它将会捕获所有exception,而不仅仅是XYZException 。 这似乎是一个相当经常发生的模式。 我知道我可以使用#pragma warning disable 0168来压制警告,但我并不真的觉得这是一个非常优雅的解决scheme。 有没有更好的办法?

如果(条件)在C ++中尝试{…}是否合法?

例如: if (true) try { // works as expected with both true and false, but is it legal? } catch (…) { // … } 换句话说, 在if条件之后放置try-block是否合法?