Proper error handling in a custom Zend_Autoloader?
Posted
by Pekka
on Stack Overflow
See other posts from Stack Overflow
or by Pekka
Published on 2010-03-16T13:08:56Z
Indexed on
2010/03/16
13:26 UTC
Read the original article
Hit count: 228
I'm building a custom autoloader based on Zend Framework's autoloading (related question here).
The basic approach, taken from that question, is
class My_Autoloader implements Zend_Loader_Autoloader_Interface
{
public function autoload($class)
{
// add your logic to find the required classes in here
}
}
and then binding the new autoloader class to a class prefix.
Now what I'm unsure about is how to handle errors inside the autoload
method (for example, "class file not found") in a proper, ZF compliant way. I'm new to the framework, its conventions and style.
Do I quietly return false and let the class creation process crash?
Do I output an error or log message somehow (which would be nice to pinpoint the problem) and return false? If so, what is the Zend way of doing that?
Do I trigger an error?
Do I throw an exception? If so, what kind?
© Stack Overflow or respective owner