I'm just going off memory right now, but I think stack traces for
exception objects are wound up from the point which they are created,
not the point which they are thrown from. So this would mean that when
you look at the trace from the exception, it originates from the
getException method, rather than the place you are wanting to throw it from.
-ralph
Shekar C Reddy wrote:
I would suggest to incorporate a method that serves as a central
location to instantiate exception objects - a *consistent
*object-instantiation system, if you will. This method could go inside
a class that is always required/loaded so we don't have to include
another file just for this purpose. Zend_Loader, maybe? This approach
allows us to add more processing/error-handling logic to the method in
future that ripples across the framework:
//////////////////////////////////////////////////////////////////////////
static function getException( $class, $message = 'ERROR', $code = 0, ... )
//////////////////////////////////////////////////////////////////////////
{
self::loadClass( $class );
//
// Or straight require_once for performance, but then format the
class-name to instantiate...
// require_once( $class );
//
return new $class( $message, $code, ... );