exception-handling

How to route the exe exception back to VB6 app?

hi guys, i have a vb6 apps which will call the mencoder.exe which is part of the mplayer to convert some files into flv format. i'm getting this weird unhandled exception problem from mencoder whenever i try to convert this one opendivx file. At the moment, i'm unclear of whether is this codec is the culprit behind this. Either way i h...

How should I store data inside custom exceptions?

When dealing with custom exceptions, I usually inherit from Exception and then add some fields/properties to my exception class to store some additional info: public class MyException : Exception { public int ErrorCode{get;set;} public MyException() {} } In the above example, the ErrorCode value is stored in the exception...

How do you handle resources in MATLAB in an exception safe manner?

Since there is no finally clause to the try-catch block in MATLAB, I find myself writing lots of code like the following: fid = fopen(filename); if fid==-1 error('Couldn''t open file'); end try line = getl(fid); catch ME fclose(fid); rethrow ME; end fclose(fid); I find having the fclose function in two places ugly and err...

Robust Javascript Exception Handling

I am developing a DHTML/Javascript application which relies on some advanced features (DOM manipulation, AJAX, Flash communication, and more). I'm very concerned about functionality -- if problems occur, even after the application is deployed, I want to make sure I know why and how to fix them -- and also, I want to make sure the user is...

Exception handling: how granular would you go when it comes to argument validation?

I'm coding a simple little class with a single method send an email. My goal is to implement it in a legacy Visual Basic 6 project, exposing it as a COM object via the COM Interop facility. There's a detail I'm finding difficult to resolve, that being how granular should I be at validating parameters. On that light, a thing I'm really n...

DB2 Exception Handling

Hi, The problem that I am facing is primarily on Exception Handling! When an exception occurs I want to put that data in another log table with the error message. However, in DB2 I am not able to figure out a way to retrieve the corresponding error message for the raised SQLSTATE. PS: I have a stored procedure for this migration and I...

Preventing Unhandled Exception Dialog Appearing

First let me say I have read this useful article thoroughly and am using the SafeThread class from CodeProject. I get the same result whether using Thread or SafeThread. I have reduced my problem down to an app consisting of two forms each with one button. The main program displays a form. When you click that button, a new thread starts...

Does the .NET JIT optimize nested try/catch statements?

Hello: I've been thinking about nested try/catch statements and started to think about under which conditions, if any, the JIT can perform an optimization or simplification of the compiled IL. To illustrate, consider the following functionally-equivalent representations of an exception handler. // Nested try/catch try { try { ...

Handling Thread Exceptions in WCF

Our WCF services occaisionally spawn a worker thread to handle something that the client doesn't care about. The worker threads do not report any status back to the client. In fact, the service has probably already returned results to the client by the time the thread finishes. One of these background threads recently caused an except...

Exception Handling in IIS7 Integrated Pipeline Mode

I have an application hosted on IIS7 running in Integrated mode. I'm handling errors by putting the following into Web.config: <httpErrors errorMode="DetailedLocalOnly" existingResponse="Replace" defaultResponseMode="ExecuteURL" defaultPath="/Error.aspx"> <remove statusCode="500" /> <error statusCode="500" path="/Error....

mvc display exception on error page

Simple question: If I've got a generic Error.aspx page in my Shared folder (and the requisite HandleError on my controller). How do I show the exception message that triggered it? This Scott Gu post states that the functionality should be in the default Error.aspx generated with new projects, but that was Preview 4, and I'm assuming tha...

Strange exception handling practice

I have seen code like this (actually seeing another person type it up): catch (Exception ex) { string exception = ex.ToString(); } Is this code bad? If so, why? There is an appropriate "chain of catch handlers (eg more specific one above, filtering down to general catch all Exception, but in the string conversion of the Exception,...

ASP.NET Exception Handling/Logging

Hi All Is there an easy way to log all exceptions in an ASP.NET application? I'm already logging unhandled exceptions through the Application_OnError event, but I want to perform logging even when an exception is handled on a page level. Many thanks. ...

C#: Stopping a thread after an Exception

Hello! I have this code: Thread t = new Thread(() => UpdateImage(origin)); t.Name = "UpdateImageThread"; t.Start(); If method UpdateImage(origin) throw an exception, it is necessary to stop thread or it will be stoped after the exception? Thank you! ...

Trapping exceptions for logging in a C++ CLI app

I'm trying to trap any and all exceptions in a C++/CLI app so that I can log and record them (including a stack trace). So far I have some code which looked promising: [STAThreadAttribute] int main(array<System::String ^> ^args) { // Enabling Windows XP visual effects before any controls are created Application::EnableVisualStyles(); ...

catching EmptyStackException vs. Testing is Stack is empty.

I have a Stack object being worked on by multiple threads. One of the threads is a worker thread which performs a pop operation on the Stack object. I wanted to handle the case where the Stack is empty and I see two options try{ Object obj = (Object) d_stackObj.pop(); } catch (EmptyStackException e) { ...} OR if( ! d_sta...

Checked exceptions in java

Possible Duplicate: The case against checked exceptions EDIT: It appears I didn't phrase my question correctly, and I can understand the frustration. I'm looking for some information that explains where I should use checked exceptions and where I should not use it. Most of the information on this subject is one sided - love/ha...

Exceptions: Compare Message Property to Know what it Means?

Sometimes in an application, one might compare the Message text of an exception. For instance, if ex.Message.Contains("String or binary data would be truncated") then a MessageBox will be displayed for the user. This works when testing on an English-language Windows system. However, when the program is run on a system with a differen...

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

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

Order of catch clauses

When using a framework method, the description you get when you highlight over it will list the exception(s) possibly raised. Does it matter if you write the catch handlers in this order? E.g. SqlConnection.Open() can throw: System.InvalidOperationException System.Data.SqlClient.SqlException It is listed in that order. Should my catch...