It is essential that applications have a means of handling abnormal conditions without hard crashing. In this recipe, we will create a dispatcher plugin that will handle two specific types of exceptional behavior. The first one will allow us to handle HTTP 404 conditions, and the second will allow us to catch any exception that occurs in the dispatcher cycle and display a specific page notifying that an error has occurred. So, by adding this functionality, we will prevent our users from seeing a white screen of death.
This recipe uses Phalcon Developer Tools which we will use to set up a project skeleton and database access is not required.
Follow these steps to complete this recipe:
We need to have an application skeleton for experimentation. If you already have such an application, you can skip this step. Create a project skeleton using the
simple
template:phalcon project abnormal_termination simple
Now point the web browser at the root...