I’ve written error handling class which divided all errors into the normal ones (notices, warnings, …), and the critical ones.
Now I’ve found out that it’s a good practice to convert all errors into exceptions. It would also shorten my code.
However, I’m not sure how to handle this…
- Are there exceptions that don’t stop scripts execution, and exceptions that do? If there aren’t…how to differ converted errors?
- Converting errors into exception is done by calling set_error_handler() and throw new ErrorException() in there…What’s next? set_exception_handler() is called automagically?
Exceptions don’t stop script execution if they’re caught. To recognize a converted error:
Or:
Note that
ErrorExceptioncan be thrown by any piece of code, but it was meant to convert regular errors inset_error_handler()registered functions only.If the thrown
ErrorExceptionfrom your error handler function is not caught anywhere else in your code, the registered exception handler (set usingset_exception_handler()) will be called.