exception-handling

try/except doesn't seem to capture exceptions - Delphi Service Application

Hi all, I have a service written in Delphi 2007 in which I'm trying capture any unknown exceptions. Assigning a method to the on exception doesn't seem to work ('Forms.Application.OnException:=UnknownApplicationException'). The 'UnknownApplicationException' doesn't appear to get called - I attribute this to the fact that there is no form...

How to catch exceptions from gsoap?

Hello everyone! I'm currently building an iphone app based on gsoap for the communication. I'm trying to manage connection problems and I can't find any specific return statement when the device is not connected to host. Is there a way to get some kind of exceptions when running gsoap send or reicv methods? Thanks for help, Romain ...

How do appDomain provide Isolation.

In my window forms application, I create a Appdomain say sandBox. In this sandbox i excute some code Say TestMethod from TestAppdomain Class. This class is in Test.dll which is not loaded in the current appdomain (Default appdomain). Now while executing TestMethod some exception occurs, then I want the sandbox domain to be unloaded and ...

Windows Service Error Event

In ASP.Net I can use a http handler or module to catch errors. I need something equivalent for my windows service. I'm thinking something like Application.OnError += ErrorHandlingMethod; Any ideas? ...

Unhandled Win32 exception

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? ...

Efficient exception handling techniques

I am writing an application in C# that requires me to create an Array object on the fly from some dimensions the user passes in. The Array.CreateInstance() method can throw (by last count) 6 different exceptions that I would want to handle. For each exception I would want to inform the user by a simple MessageBox.Show() and a message tai...

How Exceptions are handled while designing DataLayer or any other layered architecture.

I am creating a data access layer where I want to handle exceptions that should be catched by Business layer with clear idea of the source of exception. I am doing something like this.. EDIT private void OpenConnection() { if (ConnectionState.Closed == _connection.State) _connection.Open...

When to catch boost::bad_lexical_cast

From the documentation on the boost site for lexical cast it states that when converting from a numeric type to a string type the conversion can throw a bad_lexical_cast. Clearly in this case we should always handle this exception should it be thrown. My question is, what about the other way around, going from a numeric type to a string...

Throws or try-catch

What is the general rule of thumb when deciding whether to add a throws clause to a method or using a try-catch? From what I've read myself, the throws should be used when the caller has broken their end of the contract (passed object) and the try-catch should be used when an exception takes place during an operation that is being carri...

Passing exceptions across threads in an MVC application

I need to call a few webservices while constructing an MVC page, so I'm threading the work via the threadpool, and using ManualResetEvents to to determine when I have my results. If one of the threads throws an exception though, it'll crash the app. I have exception handling set up via a Filter, but I need to get the exception back t...

Handling exceptions in a property's set/get

In the example code below I am taking a list of strings and concatenating them to a delimited string. The problem occurs when I use the setter with an empty list. The ToString method throws an ArgumentOutOfRangeException since the second parameter is a -1. How should conditions (exceptions thrown in getters/setters) like this be handl...

how to add one exception handler for a class?

Hi, I am trying to use one exception handler to handle all exceptions raised by a C++ class. is there a simple way, instead of adding the code to every member function? Thanks ...

How can I intercept and handle an AntiForgeryToken exception?

I am using jQuery to post($.post) to a controller action and return a JSON result. If there are any errors, I'm returning the error message with the JSON result and displaying it to the user with a modal. However, I'm having a lot of trouble intercepting the AFT exception. Rather than throw a 500, I just want to grab the error mes...

Global exception handling in .NET?

The whole concept of exception handling is giving me headaches. Currently, what I want to do is to handle specific exceptions that I am positively sure I can handle. On the other hand, I want to terminate the application if an exception that I dont know how to handle is thrown. When I place try-catch blocks in my source code, it looks ug...

How to handle thread exceptions in main thread, block all workers and notify them upon finishing?

I have a windows service doing some repetitive work (wcf calls) after logging programmaticaly at a web server. All calls are invoked through various threads running dependently in parallel, but if for example, the connectivity is lost, or the iis recycles, hence the inproc session management directs me to re-login, I want to handle this ...

Show error within JSF page and continue rendering it instead of redirecting to separate error page

Whenever there is an error during the load of a JSF facelet, JSF stops rendering the page at the point of the error and shows the error page instead (default behavior). I want JSF to continue rendering a page instead and show the exception/error within the page. For example if the page is loading a "portlet", which throws an exception, t...

Difference between UnhandledException and DispatcherUnhandledException in .NET

What is the difference between AppDomain.UnhandledException and Application.DispatcherUnhandledException in .NET? I need an event that is fired when any unhandled exception occurs. I have come across these two, but I dont know in what ways they differ from each other. Also, are there cases when they are not fired? ...

When to use exceptions in Java (example)

I know that this would be bad practice although I know that I would not be able to explain why. int [] intArr = ... ... try{ int i = 0; while(true){ System.out.println(intArr[i++]); } }catch(ArrayIndexOutOfBoundsException e){} I think that you are only supposed to use exceptions for things that shouldn't happen. I am...

Ruby c extensions: How can I catch all exceptions, including things that aren't StandardErrors?

In ruby, begin # ... rescue # ... end won't catch exceptions that aren't subclasses of StandardError. In C, rb_rescue(x, Qnil, y, Qnil); VALUE x(void) { /* ... */ return Qnil; } VALUE y(void) { /* ... */ return Qnil; } will do the same thing. How can I rescue Exception => e from a ruby C extension (instead of just rescue => e)...

matching (and binding) two exception classes in one case statement in scala 2.7?

I have the following code: try { < ... some JSON parsing code .. > } catch { case e:ClassCastException => throw new ParseException(body, e) case e:JSONException => throw new ParseException(body, e) } This seems overly repetitious. I tried: case e:ClassCastException | e:JSONException => thr...