07-04-2009, 04:53 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: May 2009
Posts: 178
Thanks: 9
|
Handling Exceptions
Can anyone offer some advice on how to best handle exceptions thrown by input validation i'm doing i.e. i want to make sure for example a date is in the correct format. I am using the standard php Exception class eg.
throw new Exception("That Date aint right!");
I am "catching" the error later on and outputting it however i want to avoid doing a whole lot more validation checking first but i dont want a whole load of try and catch clasues everywhere. Is there a way i can use if statements to check for the existence of an Exception object and avoid processing further unnecessary code when i already know the input is in error.
eg.
If (no Exception object in existence) {
Do further validation
}
If (no Exception object in existence) {
insert date into database
}
PS. When i get the structure correct i will then start extending the Exception class to be more specific about the type of error.
Any guidance?
Thanks.
|
|
|
|