exception-handling

Catching a specific WebException (550).

Let's say I create and execute a System.Net.FtpWebRequest. I can use catch (WebException ex) {} to catch any web related exception thrown by this request, but what if I have some logic that I only want to execute when the exception is thrown due to (550) file not found. What's the best way to do this? I can copy the exception message ...

setjmp/signal crash exception handling

I am trying to install a "crash handler" for a C OSX Carbon multithreaded application. On Windows, I can easily use the simple and efficient try{} __except{} SEH of Windows which works great. (Note these are **unrelated to C++ exceptions, these are lower level C constructs!) This is very related to a question I asked on SO previously: ...

Why does Visual Studio displays some of my exceptions on the following line instead of the faulting line?

The usual behaviour of VS is to display in yellow the faulting line : int i = 1; switch (i) { default: throw new NotImplementedException(); //this will be yellow } However, quite frequently, I've witnessed that the wrong line is coloured, like in this example : int i = 1; switch (i)...

Exception handling and memory

This may be a strange question, but do 'try-catch' blocks add any more to memory in a server environment than just running a particular block of code. For example, if I do a print stack trace, does the JVM hold on to more information. Or is more information retained on the heap? try { ... do something() } catch(Exception e) { e.pri...

How much footprint does C++ exception handling add

This issue is important especially for embedded development. Exception handling adds some footprint to generated binary output. On the other hand, without exceptions the errors need to be handled some other way, which requires additional code, which eventually also increases binary size. I'm interested in your experiences, especially: ...

C++ display stack trace on exception

I want to have a way to report the stack trace to the user if an exception is thrown. What is the best way to do this? Does it take huge amounts of extra code? To answer questions: I'd like it to be portable if possible. I want information to pop up, so the user can copy the stack trace and email it to me if an error comes up. ...

Re-raising exceptions with a different type and message, preserving existing information

I'm writing a module and want to have a unified exception hierarchy for the exceptions that it can raise. This allows users of the module to catch those particular exceptions and handle them distinctly, if needed. But many of the exceptions raised from the module are raised because of some other exception; e.g. failing at some task becau...

Throw new Exception and Application_UnhandledException

My Scenario: I'm using a Silverlight MVVM pattern. All my view models inherit from a BaseViewModel class that maintains some basic values and behaviours. One of these behaviours determines if the user is authorised to use particular functionality and returns a boolean. If the function is not located, I want to throw a new exception an...

exception handling in constructor’s initializer list

In my project I found a piece of code in which a method was getting called in constructor's initializer list. Test2(Test* pTest):m_pTest(pTest), m_nDuplicateID(pTest->getTestID()) { } I observed that there is a chance that the users of Test2 might pass NULL to the constructor. Since the pointer is used without validation ther...

Need Review Comments for my Error Logging Mechanism

On every break on the Production/QA/Dev getting to the root of the exception is very crucial and time taking process. As the web applications are in multi user environment and Stateless \ Asynchronous (HTTP) ,its really a tough job to look at the Eventviewer / log files and root cause an issue reported by the end user; Also it depends o...

User Friendly Exception Handling Libraries for WinForms (.NET)

I'm trying to find a nice library for user friendly exception handling for unhandled exceptions. I found the following one: http://www.codeproject.com/KB/exception/ExceptionHandling.aspx Is there any other similar projects out there LGPL/Free (or cheap). I'm looking for features like: User friendly crash screen Remote Logging with a...

Methods to handle exceptions in a web project using C#

What is the best way to handle exceptions occurring in catch statements. Currently we are writing the exception message to response object's write method. But I want a solution by which the user will get only a general error message that something has gone wrong but we have to get a detailed description about the error. I would like to k...

Diagnosing CLR errors in Windows Event Viewer

We have an .NET desktop application that crashed in production. How do we diagnose the error? I'd like to know the type of exception that occurred, the error message, and the stack trace. Because the exception wasn't handled by our code, we received the "This application has encountered a problem and needs to close" Windows message box....

Silerlight MVVM Exception Handling

In an MMVM application, how should exceptions be handled and bubbled? If I get an exception in my model, during an Async callback, and throw an exception, this does not get bubbled to the ViewModel. I suspect that this is because the callback is not running on the UI thread. What's the best practice for this? Mark ...

Catching an exception while using a Python 'with' statement

Hello, To my shame, I can't figure out how to handle exception for python 'with' statement. If I have a code: with open("a.txt") as f: print f.readlines() I really want to handle 'file not found exception' in order to do somehing. But I can't write with open("a.txt") as f: print f.readlines() except: print 'oops' and c...

Exception handling aware of execution flow

Edit: For personn interested in a cleaner way to implemenent that, have a look to that answer. In my job I often need to use third-made API to access remote system. For instance to create a request and send it to the remote system: #include "external_lib.h" void SendRequest(UserRequest user_request) { try { ...

How best to handle exceptions when using HttpWebResponse

I am looking for advice as to how to handle any exceptions thrown in the following code example: private string SendRequest() { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myURL); // Code initialising HttpWebRequest HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream r...

RMI/Exception handling in a custom JVM

I know that a custom JVM can behave a little differently, and I'm trying to see if my observed behavior is the same as the real JVM. Also, I'm looking for some way to consistently make this stuff work. The worst part I've been seeing is that exceptions are being completely eaten by the JVM. For instance: public myMethod(String test) ...

How to get the method call history?

I am trying to get the list of calls made from the beginning of a try block to the exception. In the code below, when I fall into the Catch block, the StackTrace in the Exception object is the following : at ConsoleApplication.Program.MethodC() / at ConsoleApplication.Program.Main(String[] args). This is totally expected, but doesn't hel...

Is there a difference between "throw" and "throw ex"?

There are some posts that asks what the difference between those two are already. (why do I have to even mention this...) But my question is different in a way that I am calling "throw ex" in another error god-like handling method. public class Program { public static void Main(string[] args) { try { ...