exception-handling

Preventing thread from calling std::terminate() on detach after handled exception

半世苍凉 提交于 2020-01-06 07:50:21
问题 I have my own thread class that is intended to help safely manage exceptions. It looks like this: (skipped other constructors and mutexes for simplicity) class ExceptThread : public std::thread { public: template<typename Func, typename... Args> ExceptThread(Func&& f, Args&&... args) : std::thread([] (Args&&... args) { try { return f(args...); } catch(...) { exc = std::current_exception(); } }, args...) { } // skipped other constructors etc. //... void check() { if(exc) { std::exception_ptr

How to add model attributes to the default error page

限于喜欢 提交于 2020-01-06 07:11:18
问题 What is the best way to handle default page not found error when a user requests a url that doesn't have any mapping in the application (e.g. a url like /aaa/bbb that there is no mapping for it in the application) while be able to add model attributes to the page? 回答1: There is some anserws in SO but those have caused me other problems and more importantly they don't state how to add model attributes to the error page. The best solution I have found is this: Create a controller that

How to add model attributes to the default error page

纵然是瞬间 提交于 2020-01-06 07:11:06
问题 What is the best way to handle default page not found error when a user requests a url that doesn't have any mapping in the application (e.g. a url like /aaa/bbb that there is no mapping for it in the application) while be able to add model attributes to the page? 回答1: There is some anserws in SO but those have caused me other problems and more importantly they don't state how to add model attributes to the error page. The best solution I have found is this: Create a controller that

Throwing a XML Web Service Exception for invalid username / password

三世轮回 提交于 2020-01-06 05:59:46
问题 I've created a web service and am using a Soap header for authentication, as described here: http://aspalliance.com/805 I've adapted it, so that in every method, it calls a seperate "authenticate" method, which searches username and password in the db, and returns true or false. My question is, within this method, if it returns false (ie, the user isn't validated) how should i throw an exception, that filters back to the consumer application? 回答1: First of all, you'd do better to add a Login

Can I catch exceptions thrown from one thread in another thread in Objective-C?

三世轮回 提交于 2020-01-06 03:40:06
问题 Is it possible to catch an exception thrown from one thread in another thread? For example, I am spawning a thread from my main thread. The spawned thread may throw uncaught exceptions. Is it possible to have the spawning thread catch these exceptions? One solution would be to catch the exceptions from the entry point of the spawned thread and "handle" the exception by posting an NSNotification . Then, the spawning thread can listen for these NSNotification s. However, this solution seems a

Firebird - handling exception's custom-message [duplicate]

匆匆过客 提交于 2020-01-06 01:18:49
问题 This question already has answers here : In FirebirdSql, how to return exception message from procedure (2 answers) Closed 2 years ago . I am using Firebird 2.5. I'm trying to handle user defined exception custom message in a stored procedure. I have two procedures. The first one raise exception with additional information (custom exception message). The second one selects data from the first one and it is trying to handle the exception. I have problem with reading the custom message of the

C# why throw errors [closed]

断了今生、忘了曾经 提交于 2020-01-05 13:17:31
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Im not getting the throw keyword, why use it? What are the benefits of it? As of now I've got this in my UI class: try { Classreference.MethodToRun(); } catch (Exception ex) { MessageBox.Show(ex.ToString(),

Statements within catch block is not executing

橙三吉。 提交于 2020-01-05 09:20:51
问题 I wrote a piece of code to catch specific exception with help from this link. It is like: catch (SQLException sqle) { // TODO Auto-generated catch block String sqlMessage = sqle.getMessage(); String sqlState = sqle.getSQLState(); int vendorCode = sqle.getErrorCode(); System.out.println("Exception occurred:"); System.out.println("Message: " + sqlMessage); System.out.println("SQL state: " + sqlState); System.out.println("Vendor code: " + vendorCode); } But I am getting output as: java.sql

The best practise when to use PHP exception handling

半腔热情 提交于 2020-01-05 08:52:32
问题 I know this question has been asked before numorous times but they seem to have a desktop application background and not web application. I am currently building a web application using PHP. I'm going to use a controller and model file to demonstrate my question. Controller file This file calls upon the database to query and fetch data <?php public function index() { $this->database->query("SELECT user_name, FROM test WHERE user_name = :user_name"); $this->database->execute_query("jim");

Exception/Error handling in NASM assembly

时光毁灭记忆、已成空白 提交于 2020-01-05 04:47:06
问题 How do I handle errors in NASM assembly? For example I have this code to read user Input: mov eax,3 mov ebx,0 mov ecx,Buffer mov edx,BUFFERLENGTH int 80H If for some reason this system call cannot be executed, I'd like to have the program jump to a label that prints "An error has occured" or something like that. How do I do that? Also, is it possible to get the name of the exception or error code? Thanks 回答1: After the kernel call, EAX is going to have two possibilites; Number of characters