TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-04-2009, 04:53 PM   #1 (permalink)
The Acquainted
 
captainmerton's Avatar
 
Join Date: May 2009
Posts: 178
Thanks: 9
captainmerton is on a distinguished road
Default 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.
captainmerton is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception Handling captainmerton Absolute Beginners 4 05-17-2009 01:07 PM
Error handling Ross TalkPHP Developer Team 0 01-17-2009 10:27 PM
Error Handling and Exceptions Farmer Absolute Beginners 3 12-11-2008 06:41 PM
Exceptions and suppressing mysqli errors delayedinsanity Advanced PHP Programming 12 05-07-2008 07:27 PM
Using Exceptions to Provide Better Feedback Wildhoney Tips & Tricks 5 11-19-2007 06:55 AM


All times are GMT. The time now is 02:29 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design