Best way to handle error descriptions
Posted: Wed Dec 24, 2008 9:22 pm
If your API constains error description messages, what is the best design(A or B??)
$code = array(
'100'=>'message in english here',
'110'=>'message in english here');
//OPTION A
include 'error_in_{$lan}.php'; //$lan is 'es','en', etc..
$error = class->function(xxx);
echo $codes[$error];
//OPTION B
$error = class->function(xxx);
$error->getDescription($lan);
$code = array(
'100'=>'message in english here',
'110'=>'message in english here');
//OPTION A
include 'error_in_{$lan}.php'; //$lan is 'es','en', etc..
$error = class->function(xxx);
echo $codes[$error];
//OPTION B
$error = class->function(xxx);
$error->getDescription($lan);