exception-handling

getting error not all code paths return value by c# compiler

廉价感情. 提交于 2020-01-04 05:08:28
问题 This is a basic string reverse program and I want to do some level of exception handling in it. But during compilation it gives me an error "NOt all code paths return value. I am not able to find out why public static string Reverse(string s) { try { if (string.IsNullOrEmpty(s)) { throw new NullReferenceException(); } char[] c = s.ToCharArray(); int start = 0; int end = c.Length - 1; char temp; while (start < end) { temp = c[start]; c[start] = c[end]; c[end] = temp; start++; end--; } return

Unhandled Win32 exception

梦想的初衷 提交于 2020-01-04 04:10:16
问题 At runtime, when myApp.exe crashes i receive "Unhandled Win32 exception" but how would i know which exception was occurred? where did something went wrong? 回答1: For a Native C++ app see my earlier answer here: Detect/Redirect core dumps (when a software crashes) on Windows for catching the unhandled exception (that also gives code for creating a crash dump that you can use to analyse the crash later. If the crash is happening on a development system then in Visual Studio (I'm assuming you're

Bug report form on error page

本小妞迷上赌 提交于 2020-01-03 18:59:12
问题 I have a JSF web application in JBoss 7.1 and Richfaces 4.1. I tried to configure a custom error page in web.xml but came across the problem, that this does not work for AJAX requests. As a solution I tried to use Omnifaces FullAjaxExceptionHandler which displays the error page fine. However I wanted to add a form that allows the user to enter additional information and send this, along with the exception, as an email to me. The problem is that on the error page, the submit buttons does not

When are MVar operations guaranteed to be uninterruptible?

倾然丶 夕夏残阳落幕 提交于 2020-01-03 18:55:08
问题 The documentation for Control.Exception describes which operations can have async exceptions thrown, even within a mask ed block, saying: "The following operations are guaranteed not to be interruptible" takeMVar if the MVar is definitely full, and conversely putMVar if the MVar is definitely empty In what cases is an MVar "definitely" full or empty from the compiler's point of view? Is that even well-enough defined to enable reasoning about whether my code will break without handling async

When are MVar operations guaranteed to be uninterruptible?

孤街醉人 提交于 2020-01-03 18:55:06
问题 The documentation for Control.Exception describes which operations can have async exceptions thrown, even within a mask ed block, saying: "The following operations are guaranteed not to be interruptible" takeMVar if the MVar is definitely full, and conversely putMVar if the MVar is definitely empty In what cases is an MVar "definitely" full or empty from the compiler's point of view? Is that even well-enough defined to enable reasoning about whether my code will break without handling async

Java Throwing exceptions vs returning response in catch

吃可爱长大的小学妹 提交于 2020-01-03 18:45:48
问题 I know a lot has been discussed around exception handling, however I need some advice specific to my situation. I am currently working on a Spring MVC application with Controller->Services->DAO layers. The service classes catch mainly two kinds of exceptions HibernateException and IOException . HibernateException because service needs to perform rollback if a transaction did not succeed and IOException since it is an unchecked exception and needs to be caught or thrown and I prefer the first

Will throwing an exception in a catch block lead to two exceptions being in flight?

半世苍凉 提交于 2020-01-03 17:12:47
问题 Consider the following C++ code: class MyException {}; void someFunction() { try { /// ... code that may throw } catch(std::exception& e ) { throw MyException(); } } Question Is the exception e absorbed at the beginnging of the catch block or at the end of the catch block? In the second case throwing the new exception would result in having two exceptions in flight, what is not what I want. I want to absorb the std::exception and start one of my own type. 回答1: No. That's how one should do it.

Is it safe to use an exception outside the catch statement if it is held in a std::exception_ptr?

若如初见. 提交于 2020-01-03 14:20:12
问题 I have a std::exception_ptr with an exception inside it. I am going to invoke std::rethrow_exception to get the actual exception, will the exception be valid after the catch statement? My guess here is that since I still hold the std::exception_ptr it will still be valid. See the example: std::exception_ptr ePtr = initialize_somewhere_else(); std::runtime_error* a=NULL; try { std::rethrow_exception(ePtr); } catch(std::runtime_error& e) { a = &e; } std::cout << a << ", " << a->what() << std:

Why property ''cause" of Exception is repeating forever?

∥☆過路亽.° 提交于 2020-01-03 12:43:32
问题 While debugging with eclipse IDE an HttpClientErrorException I noticed that property "cause" contains a reference to the error itself, so I went through and there it was the property "cause" again, and again ... forever. Why this property contains a reference to itself? 回答1: Throwable declares private Throwable cause = this; If the cause is not initialized, either by passing a cause in the constructor or by calling initCause , it will continue to point to this . Note that consequently

llvm exceptions - RaiseException “?:Unknown signal”

独自空忆成欢 提交于 2020-01-03 12:32:34
问题 I'm trying to get exceptions working with llvm for a very simple example, that I can later build on but i'm running into some real difficulties and i'm not sure why. I got clang to give me the following llir code, that I am passing into the MCJIT ; llvm-as c++exn.ll && llvm-ld -native c++exn.bc -lstdc++.6 && ./a.out %"class.std::ios_base::Init" = type { i8 } %"class.std::basic_ostream" = type { i32 (...)**, %"class.std::basic_ios" } %"class.std::basic_ios" = type { %"class.std::ios_base", %