Wrapping Exceptions

exception

Solution

It's better to create a new exception, with a pointer to the original exception. You can print out both the new information and the message from the old exception.

see this info on InnerException

http://msdn.microsoft.com/en-us/library/system.exception.innerexception.aspx

This is the standard approach, which is why Microsoft has built in support for this into their Exception class.

Problem

I frequently want to add useful information to the message of an exception. Since the Message property of the Exception class does not have a public setter one option is to wrap the exception raised in another. ``` //... catch(Exception e) { throw new Exception("Some useful information.", e); } ``` Is this bad practise and if so what is the alternative?

Original source