Hacker News new | ask | show | jobs
by babyrainbow 3540 days ago
>set_error_handler("myErrorHandler"); function myErrorHandler($errno, $errstr, $errfile, $errline) { throw new Exception($errstr, $errno); } Is all you need.

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...