exception-handling

Refactor Exception Handling

Ok i have sinned, i wrote too much code like this try { // my code } catch (Exception ex) { // doesn't matter } Now i'm going to cleanup/refactor this. I'm using NB 6.7 and code completion works fine on first writing, adding all Exception types, etc. Once i have done the above code NB do not give more help. Do you know a way t...

Exception handling loop puzzle

I recently encountered a behavior that I've never seen before. I cannot quite understand what's going on most likely due to lack of fundamental knowledge with regards to the inner workings Exception Handling - or maybe I am just missing something obvious. I recently added exception handling to an app as a sort of fallback in case of un...

Custom Exception Filter not being hit in asp.net MVC

I have a custom exception filter that I'm using to catch a custom exception that I wrote but for some reason when I throw my exception, it's not ever getting to the filter. Instead I just get an error that my exception was not handled by user code. Can anyone please provide some advice/assistance as to how I should have this set up? R...

F# exception handling constructs

Why doesn't F# naturally support a try/with/finally block? Doesn't it make sense to try something, deal with whatever exception it throws, at least to log the exception, and then be sure that some code executes after all that? Sure, we can do try try ... with ex -> ... finally ... But that seems too artificial, i...

T-SQL Reporting Duplicate Key Exception to user in simple manner

I have a simple country table using a identity column for the primary key. There are also columns used to contain the 2 letter and 3 letter ISO-3166 Country Codes. Each of these columns is defined as a unique index. On Inserts/Updates I want to simply notify the user if the ISO Code entered is already in use. I am relying on the databas...

Proper way to handle InnerException trees?

I'm working with some classes which, when throwing, have a relatively deep InnerException tree. I'd like to log and act upon the innermost exception which is the one having the real reason for the problem. I'm currently using something similar to public static Exception getInnermostException(Exception e) { while (e.InnerException !...

How to consolidate validity checking and exception throwing in Java?

I am implementing an interface which defines a method that can throw an exception if the parameters are not valid. What constitutes valid parameters depends on the implementing class. The interface also defines an isValid() method which can be used to check the parameters but returns a boolean rather than throwing an exception. I have fo...

In ASP.NET Should we call Session.Abandon() when an unhandled exception occurs ?

In ASP.NET should we call Session.Abandon() when an unhandled exception occurs ? There are many end users that hit "refresh" or "back" in the web browser in order to resubmit the request. I would like to prevent this behavior by resetting the context. TIA. ...

How many statements in a try/catch statement?

Should I put multiple statements in a try and then catch all possible exceptions, or should I put only one statement in the try statement? Example: try { MaybeThrowIOException(); MaybeThrowFooBarException(); return true; } catch (IOException e) { // ... } catch (FooBarException e) { // ... } Or try { MaybeThr...

Java unreported exception

While learning Java I stumble upon this error quite often. It goes like this: Unreported exception java.io.FileNotFound exception; must be caught or declared to be thrown. java.io.FileNotFound is just an example, I've seen many different ones. In this particular case, code causing the error is: OutputStream out = new BufferedOutpu...

ESB Toolkit.exceptionHandling Error - The application does not exist - Any ideas?

Hello I am getting following error while attempting to run the Management Portal for ESB Toolkit 2.0: Event Type: Warning Event Source: ENTSSO Event Category: Enterprise Single Sign-On Event ID: 10536 Description: SSO AUDIT Function: GetConfigInfo (SSOProperties) Application Name: ESB Toolkit.exceptionHandling Error Code: 0xC000...

What Exception Type to throw for strings

If I've got the following, really for any string where you check IsNullOrEmpty and it turns up empty, what kind of exception type should one throw, and it's not a argument to a method? I always have a hard time picking exception types because there are so damn many of them. And this is just grabbing a value from the web.config and chec...

JSF, Exception Logging using a aopalliance MethodInterceptor

I would like to log the exceptions that are thrown when serving JSF files in the same way other exceptions are logged in our web application. We annotate classes with logged exceptions with @LoggedExceptions and a MehtodInterceptor is matched against those classes with Guice AOP (This should be very similar for other implementations of ...

Will C++ exceptions safely propagate through C code?

I have a C++ application that calls SQLite's (SQLite is in C) sqlite3_exec() which in turn can call my callback function implemented in C++. SQLite is compiled into a static library. If an exception escapes my callback will it propagate safely through the C code of SQLite to the C++ code calling sqlite3_exec()? ...

Is it abusive to use IDisposable and "using" as a means for getting "scoped behavior" for exception safety?

Something I often used back in C++ was letting a class A handle a state entry and exit condition for another class B, via the A constructor and destructor, to make sure that if something in that scope threw an exception, then B would have a known state when the scope was exited. This isn't pure RAII as far as the acronym goes, but it's a...

set switch to trigger custom filter in asp.net mvc for exception handling

is there something I need to "turn on" to allow my asp.net mvc application to utilize custom exception filters? I posted in here last week with code samples to a custom filter I wrote that should catch and handle a custom exception but for some reason I keep getting an error on my throw line indicating that the exception was not handled...

How to handle DataIntegrityViolationException in Spring?

I need to show custom messages in my Spring 3.0 application. I have a database with Hibernate and there are several constraints. I have doubts in how DataIntegrityViolationException should be handled in a good way. I wonder if there is a way to map the exception with a message set in a properties file, as it is possible in Constraints va...

Differences in OCX and DLL exception handling?

I know a (vc++) ocx is an ActiveX control, and a (vc++) dll is a collection of functions. I've found that being called from a vb.net application, the catching of some exceptions could behave differently if the exception is being thrown from inside the ocx or inside a function that comes in a dll. So my question is: From a point of view ...

best practice to handle this exception case

let's say methodA and methodB will both throw a couple of types of exceptions, and some exceptions are of the same type, some are not, so what's the best practice to handle this? style A: void foo() { try { methodA(); } catch (exceptionTypeA) { handleA; } ...

C# try {} catch {}

hi and thanks for reading. im a newbie in programming and C# and sockets programming. in my code i try and catch problems to provide fault tolarence in my app. the following: catch (ArgumentNullException e) { OnNetworkEvents eventArgs = new OnNetworkEvents("Network Unavailable", e.Message); OnUpda...