When a critical error brings joy ...
Having recently read on the drunken head “ Handling Errors and Exceptions in PHP ”, I decided to put this knowledge into practice. Honestly, 6 hours ago, I didn’t know where it would lead me, but in the end, now my scripts with an error light up such a pretty screen:
To be honest, there’s not much PHP here. Create your own subclass ; with the help, we order PHP to throw our new exception whenever an error or warning occurs; and wrap all our code in . In short, everything is as in the above article. Most of the time, I spent on formatting styles and pictures (which, by the way, are inserted using url-data; i.e., my class turned out to be independent of external resources).
All the necessary code is concentrated in one file , which is part of the future framework ( NB! ... in its infancy ;-)). Before you include this file in your project, you need to perform the following operations with it:
Exception
set_error_handler
try { … } catch () { … }
“Where is the code, chatterbox?”
All the necessary code is concentrated in one file , which is part of the future framework ( NB! ... in its infancy ;-)). Before you include this file in your project, you need to perform the following operations with it:
- Get rid of the "jammer" in the first line;
Aero()->get_option(...)
Replace all references with the second parameter of the called method. (For example, itAero()->get_option('catch_errors', E_ALL, 'error_handler')
turns into justE_ALL
.)