[eluser]xwero[/eluser]
I think option 1 is a bit over-abstracted, certainly if it is a stand alone library. You would have to check each time you change something if you don't have overlapping numbers and you have to keep track of them.
I go with option 2 with a few changes
- add an public/not public flag for the errors so it can be dealt with in the controller (redirects too)
- put the error strings in a language file
- on success return an empty string instead of a boolean
To add it all up in code you would have something like this in your controller
Code:
$check = register($password, $username);
if(empty($check))
{
// success
}
else
{
$temp = explode('|',$check);
if($temp[0] == 0) // public error
{
// show error + optional redirection
}
else
{
// show generic error + developers choice + optional redirection
}
}
If you go with option 3 i think the database failure/file error will be skipped often because it should work, even CI has this 'sin'. I guess it's up to the developer to decide which errors should be cached for display.