exception-handling

How can I stop HIToolbox from catching my exceptions?

 ̄綄美尐妖づ 提交于 2019-12-07 07:27:38
问题 This question follows on from my other question on why my app isn't being brought down by exceptions. The Problem When an exception is thrown on the main thread via an Action, the app still doesn't crash. As per Dave's answer to my original question, I've implemented the reportException category on NSApplication and set the uncaught exception handler. Code I've got the following in my app delegate, which I've hooked up to a button in my UI to test. -(IBAction)crashOnMainThread:(id)sender {

C++ Do I need to write throw clause for a function everywhere?

吃可爱长大的小学妹 提交于 2019-12-07 07:22:18
问题 Before Consider to have a class and a global function: This is, for example, usefulfuncts.hpp void dosome(int a, int b) throw (std::exception); This is usefulfuncts.cpp void dosome(int a, int b) throw (std::exception) { //... } And this is aclass.hpp class aclass { // Members... friend void dosome(int a, int b) throw (std::exception); // Members... }; After (what I would like that to be) Ok! I would like to understand if it is strictly necessary to write everytime the throw clause. So for

ContinueWith TaskContinuationOptions.OnlyOnFaulted does not seem to catch an exception thrown from a started task

一世执手 提交于 2019-12-07 06:33:17
问题 I'm trying to catch an exception thrown from a task method using ContinueWith and OnlyOnFaulted like below. However I get an unhandled exception while I try to run this code. I'd like the task to run to completion since I have handled the exception already. But Task.Wait() runs into AggregateException. var taskAction = new Action(() => { Thread.Sleep(1000); Console.WriteLine("Task Waited for a sec"); throw (new Exception("throwing for example")); }); Task t = Task.Factory.StartNew(taskAction)

Polly policy to log exception and rethrow

泄露秘密 提交于 2019-12-07 06:24:15
问题 I consider to use Polly to create policy to log exception and rethrow. I didn't find an existing method that allow it out of the box , but some options that I see are Fallback // Specify a substitute value or func, calling an action (eg for logging) if the fallback is invoked. Policy.Handle<Whatever>() .Fallback<UserAvatar>(UserAvatar.Blank, onFallback: (exception, context) => { _logger.Log(exception, context); throw exception; }); Question: is it ok to throw exception from Fallback? Timeout

How to catch all exceptions with CherryPy?

社会主义新天地 提交于 2019-12-07 06:22:44
问题 I use CherryPy to run a very simple web server. It is intended to process the GET parameters and, if they are correct, do something with them. import cherrypy class MainServer(object): def index(self, **params): # do things with correct parameters if 'a' in params: print params['a'] index.exposed = True cherrypy.quickstart(MainServer()) For example, http://127.0.0.1:8080/abcde: 404 Not Found The path '/abcde' was not found. Traceback (most recent call last): File "C:\Python27\lib\site

Throwing a new exception while throwing an old exception

不羁的心 提交于 2019-12-07 06:09:01
问题 If a destructor throws in C++ during stack unwinding caused by an exception, the program terminates. (That's why destructors should never throw in C++.) Example: struct Foo { ~Foo() { throw 2; // whoops, already throwing 1 at this point, let's terminate! } }; int main() { Foo foo; throw 1; } terminate called after throwing an instance of 'int' This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information. If a

What is it called when I say “catch (Exception e) {}” in Java?

放肆的年华 提交于 2019-12-07 06:08:43
问题 I am not sure about this answer. I cant find it anywhere. Is it the empty error handling?! 回答1: It is known as suppressing the exception, or swallowing the exception. May not be a very good practice, unless commented with a very good reason. 回答2: We affectionately call this "eating the exception" at work. Basically, it means that something bad occurred, and we are burying our head in the sand and pretending it never happened. At the very least, a good practice is to have a logger.error(e)

How to disable floating point unit (FPU)?

半腔热情 提交于 2019-12-07 06:02:42
问题 I want to disable FPU/MMX/SSE instructions in x86 system, and I will implement a handler for the Device-Not-Available exception. I have referred to Control register wiki page; It seems that I have to set some flags in cr0 register. How to set these flags in cr0 and Do this work do at boot time? 回答1: The Linux kernel code for managing FPU state can be found in arch/x86/kernel/traps.c, do_device_not_available() . By default, the Linux kernel disables the FPU for all processes, and enables it on

Visual studio with xUnit, Assert.Throws and “Exception was unhandled by user code”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 05:46:36
问题 i am trying to run tests inside a dll application (VS2010/C#) using using xUnit 1.8.0.1549. To do so i run xUnit via visual studio using "Start External Program" under "Start Action" in the project properties, running the dll via the GUI runner (C:\mypath\xunit.gui.clr4.x86.exe). I want to test if some methods raise exception, to do so, i use something like the following: Assert.Throws<Exception>( delegate { //my method to test... string tmp = p.TotalPayload; } ); The problem is that the

Visual Studio 2015 unexpectedly breaking on handled exceptions

允我心安 提交于 2019-12-07 05:37:17
问题 An image being worth a lot of words, how is the following possible: As can be seen, Visual Studio 2015 (latest version) breaks while Common Language Runtime Exceptions under Exception Settings is unchecked, Enable Just My Code under Tools > Options > Debugging is checked, and the exception is clearly handled (within a try/catch block). The line failing and causing the break is a call to an external API (which is somewhat buggy, hence the try/catch block). Am I missing something that would