The system I am working on is highly modular and there is the possibility of modules that are added by 3rd parties... therefore I would like to add more intellegent error handling than just the default (and fatal) HTTP 500 error.
I would like to handle/intercept a "Class not found" error by throwing an exception instead. Obviously errors like this should be caught during development, but throwing an exception instead of a fatal error would at least allow a recovery pattern on a production system.
I have looked into the Event Manager for \Phalcon\Loader and I see that there are 3 "loader" events that I can work with (beforeCheckClass, pathFound, afterCheckClass)... but there doesn't appear to be the critical one... pathNotFound!!
For example:
// works... fires all 3 events
$widget = new \Cool\Widget();
// non-existant class... fires only "beforeCheckClass" and "afterCheckClass" events
try {
$fake = new \Cool\Fake();
} catch (\Exception $e) {
die('<pre>' . $e->__toString() . '</pre>'); // never called
}
What are my options?