Tag: 线程exception

我应该了解C ++中的结构化exception(SEH)?

每个C ++开发者都应该知道结构化exception有哪些重要的一点?

为什么优秀的程序员有时会默默吞下exception?

我知道这是邪恶的,但是我已经看到了吞下一个好程序员编写的代码中的exception。 所以我想知道这个不好的做法是否可以有至less一个积极的一面。 换句话说,这很糟糕,但为什么好的程序员在极less数情况下使用它呢? try { //Some code } catch(Exception){}

清晰或不清楚:C#多个三元运算符+抛出如果不匹配

你觉得下面的C#代码是可读的吗? private bool CanExecuteAdd(string parameter) { return this.Script == null ? false : parameter == "Step" ? true : parameter == "Element" ? this.ElementSelectedInLibrary != null && this.SelectedStep != null : parameter == "Choice" ? this.SelectedElement != null : parameter == "Jump" ? this.SelectedStep != null : parameter == "Conditional jump" ? false : false.Throw("Unknown […]

如果没有人调用interrupt(),可以忽略InterruptedException吗?

如果我创build自己的线程(即不是线程池)和某处我调用sleep或任何其他可中断的方法,可以忽略InterruptedException, 如果我知道代码中没有其他人正在线程上执行中断 。 换句话说,如果线程应该和JVM一样长,意味着线程不可中断,那么假设InterruptedException 永远不会被调用,因此可以吞噬exception呢?

设置.NETexception对象的InnerException

我如何设置Exception对象的InnerException属性,而我在该对象的构造函数? 这归结为查找和设置没有setter的属性的后台字段。 顺便说一句:我已经看到这个( http://evain.net/blog/articles/2009/05/01/getting-the-field-backing-a-property-using-reflection ),但寻找非基于IL的解决scheme,如果可能的话。 Exception构造函数是创buildExceptiontypes的地方,所以我不能使用基类构造函数MyException():base(…)来调用它。

C ++“new”运算符能否在现实生活中抛出exception?

new运营商能否在现实生活中抛出exception? 如果是的话,除了杀死我的应用程序之外,还有什么办法可以处理这种exception吗? 更新: 有没有真正的世界, new应用程序检查失败,并恢复时,没有内存? 也可以看看: 你多久检查一次C ++新指令中的exception? 在C ++中testing“新”的返回是否有用? 在任何情况下,新的返回NULL?

exception消息(Python 2.6)

在Python中,如果我打开一个不存在的二进制文件,程序将退出并显示错误信息: Traceback (most recent call last): File "C:\Python_tests\Exception_Handling\src\exception_handling.py", line 4, in <module> pkl_file = open('monitor.dat', 'rb') IOError: [Errno 2] No such file or directory: 'monitor.dat' 我可以用“try-except”来处理这个问题,比如: try: pkl_file = open('monitor.dat', 'rb') monitoring_pickle = pickle.load(pkl_file) pkl_file.close() except Exception: print 'No such file or directory' 我怎么可能在catch Exception中打印下面这行? File "C:\Python_tests\Exception_Handling\src\exception_handling.py", line 11, in <module> pkl_file = open('monitor.dat', 'rb') […]

debugging器不会在asynchronous方法中打破/停止exception

当一个debugging器连接到一个.NET进程时,它通常会在引发未处理的exception时停止。 但是,当你在一个async方法,这似乎不工作。 我以前尝试过的场景在以下代码中列出: class Program { static void Main() { // Debugger stopps correctly Task.Run(() => SyncOp()); // Debugger doesn't stop Task.Run(async () => SyncOp()); // Debugger doesn't stop Task.Run((Func<Task>)AsyncTaskOp); // Debugger stops on "Wait()" with "AggregateException" Task.Run(() => AsyncTaskOp().Wait()); // Throws "Exceptions was unhandled by user code" on "await" Task.Run(() => AsyncVoidOp()); Thread.Sleep(2000); } […]

如果catch和finally块都抛出exception,会发生什么?

如果catch和finally块都抛出exception,会发生什么?

Java – 在try / catch中执行try / catch是不好的做法吗?

我有一些代码,如果发生exception,我想执行。 但是那个代码也会产生一个exception。 但是我从来没有见过人们在另一个尝试/抓住里面试一试。 是我做的不好的做法,也许有这样做的一个更好的方法: Uri uri = Uri.parse("some url"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); try { startActivity(intent); } catch (ActivityNotFoundException anfe) { // Make some alert to me // Now try to redirect them to the web version: Uri weburi = Uri.parse("some url"); try { Intent webintent = new Intent(Intent.ACTION_VIEW, weburi); startActivity(webintent); } catch […]