The general rule is 
1. if you can't handle the exception don't.
2.  If you are doing business logic throw a custom exception for when you need 
to fail a process. 
3.  Inherit from exception and do not use application exception.

I think your code falls into rule 1.
It's up to the ui to catch and decide if they want to let the user try another 
directory.

Davy.
------Original Message------
From: Bec Carter
Sender: ozdotnet-boun...@ozdotnet.com
To: ozDotNet
ReplyTo: ozDotNet
Subject: Custom exception?
Sent: 9 Jun 2010 03:59

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


BBM pin:2589AEE0

Reply via email to