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: ozdotnet-boun...@ozdotnet.com [mailto:ozdotnet-boun...@ozdotnet.com] 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--

Reply via email to