Posted by Yarco on 08/16/07 07:38
When i am coding something, i always need to do some error control on
it.
For example:
<?php
function check()
{
// the following vars from somewhere
if (empty($username))
{
$error['username'] = 'empty user name';
return false;
}
if (//...)
{
}
return false;
}
try
{
// to add a record
}
catch(Exception $e) // but failed, because you can't add record again
some column is uniq.
{
$error['db'] = $e->getMessage();
}
?>
So $error will contain something like:
'db' => "SQLSTATE[23000]: Integrity constraint violation: 1062
Duplicate entry '1-5' for key 'rate_guid_accountId'"
But i want to let user know they do not do such thing but now such
professional words.
How can i do it?
Navigation:
[Reply to this message]
|