Yes, no doubt on this one - always wrap the original exception inside
the custom one

On Wed, Jun 9, 2010 at 1:13 PM,  <[email protected]> wrote:
> Note that if you use the latter approach then you should always include
> the original exception as an inner exception to the
> ReportGenerationException.
>
> It's very frustrating to debug an application and get a general
> exception that doesn't include all the information you need or at least
> could have available simply because the developer decided to throw away
> information for no good reason (and I don't think there is ever a good
> reason not to include the inner exception - if no one cares then they
> don't have to look at it, and if they do they have a full stack trace
> and details of the *original* exception).
>
> Ben
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of David Kean
> Sent: Wednesday, 9 June 2010 10:03 AM
> To: ozDotNet
> Subject: RE: Custom exception?
>
> Does the user of the class specify the directory? Or is this hidden from
> them? If the former, it's entirely appropriate to throw IOExceptions
> because that's what they would expect. If the later, then throw the
> custom exception.
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Bec Carter
> Sent: Tuesday, June 08, 2010 7:00 PM
> To: ozDotNet
> Subject: Custom exception?
>
> Hi!
> >From the more experienced programmers here, when is it appropriate to
> create custom exceptions?
> I am finding a mix of opinions around.
>
> eg. I have a class which generates reports. Part of the process is to
> create a directory if it does not already exist. If the create directory
> fails several types of exceptions can be thrown like
> System.UnauthorizedAccessException, DirectoryNotFoundException and so
> on. Should the caller of this class care about all of these or should
> they just worry about catching a ReportGenerationException which tells
> them exactly what went wrong?
>
> Cheers. --Bec--
>
>
> This email is intended for the named recipient only.  The information it 
> contains may be confidential or commercially sensitive.  If you are not the 
> intended recipient you must not reproduce or distribute any part of this 
> email, disclose its contents to any other party, or take any action in 
> reliance on it.  If you have received this email in error, please contact the 
> sender immediately and delete the message from your computer.
>

Reply via email to