Due to the clamor on the list for lazy-loading of exceptions JIT, and
based in part on suggestions in that thread, I've added
Zend::exception() to the Zend class in both the incubator and core in
subversion.

As mentioned on the list, it does not actually throw the exception. The
reason for this is so that the throw happens at the location in the code
where it's necessary, not in a method in an unrelated class. This has
the benefit of putting the location of the throw as the first element
in the trace, making debugging more straightforward.

Additionally, if you need to manipulate the exception before throwing
it, returning the exception instead of throwing it makes this possible.

Usage is as follows:
    
    // Assuming require_once 'Zend.php'; has been called previously
    throw Zend::exception('Zend_Acl_Exception', 'Incorrect permissions');

You can also optionally pass an exception code. The method uses
Zend::loadClass() to load the exception class, so the class name needs
to follow ZF naming conventions.

Another change made in the Zend class was to isReadable(). The algorithm
being used previously was a tad bit heavy performance-wise; the change I
made gives a 10-fold increase in performance, while retaining backwards
compatability.

Enjoy!

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to