in reply to The art of error handling
I think you're checking the user input at the wrong point if you're relying on the DBI::errstr to tell you that user input is invalid.
From a security and usability stand point you should test your data long before you try and dump it into the database. I think the security part stands on it's own without further explanation.
The earlier you detect a problem the easier it tends to be to deal with it. What if this program routinely took 10 or 15 minutes to get to the point where the insert happens and DBI::errstr is populated? Your users will be upset.
Better options for detecting and reporting errors in web apps (in order of increasing ease of user interaction):Year Month Day [2000|v] [January|v] [26|v](bad ascii rendering as form and table tags are filtered) You get back three values that you know are acceptable and can be concatenated into a good looking date.
Now that format is covered (and users aren't frustrated) use a module like Date::Manip to check if a date is _valid_ (i.e. not 2000-02-31 aka Feb 31st)$date = $param{year} . "-" . $param{month} . "-" . $param{day};
If you continue down the road you're on now are you really prepared to grep DBI::errstr for every partial error string that could be tossed from within the database?
--
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: The art of error handling
by saucepan (Scribe) on Dec 20, 2000 at 10:03 UTC | |
|
Re: Re: The art of error handling
by markjugg (Curate) on Dec 22, 2000 at 07:03 UTC |