|
|
|
|
|
by colshrapnel
3540 days ago
|
|
You can make them throw actually. set_error_handler("myErrorHandler");
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
throw new Exception($errstr, $errno);
} Is all you need. They are functions - yes. If your first language was fully OOP, then probably PHP is not your language of choice. It doesn't make it bad, though. |
|
So you think boxing all kinds of errors into one generic exception type is a solution to this shortcoming of the language?
That sure feels like a 'php' solution. I will give you that. But that ain't pretty (even as a work around), and no, it does not do the job. May be if you don't know how to work with exceptions in the first place, then it might work for you. But you might end up with a code base like this [1]
[1] http://stackoverflow.com/questions/3425835/converting-errors...