Page 1 of 1

Best way to handle error descriptions

Posted: Wed Dec 24, 2008 9:22 pm
by yacahuma
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);

Re: Best way to handle error descriptions

Posted: Sat Dec 27, 2008 3:14 pm
by cptnwinky
If I understand correctly I think it would depend on how big that array of error codes gets. If it's a large array you certainly don't want to be declaring it upon every page load, that would just waste memory and processing power. Thus, including an error file would probably be the best thing. It also allows for easier abstraction.