Source for file Handler.class.php
Documentation is available at Handler.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* This class will process any Exceptions thrown by the program. Any thrown Exceptions
* should be sent to the Exception Handler through the trigger method. This can be
* done either by sending a thrown Exception to the handler, creating a new Exception and
* sending the object to trigger, or by using the trigger_error() function.
* if ( // test condition failes ) {
* throw new Gumbo_Exception ("message");
* } catch (Exception $e) {
* if ($e instanceof Gumbo_Interface_Exception) {
* $e->setFunction (__METHOD__);
* Gumbo_Error_Handler::trigger ($e);
* $e = new Gumbo_Exception ("message", ERROR_LEVEL, __FILE__, __LINE__, __METHOD__);
* Gumbo_Error_Handler::trigger ($e);
* trigger_error ("message", ERROR_LEVEL);
* The class file provides a simple function that wraps the trigger method. This function
* is simply called 'trigger (...)'. This will help from having to type the entire static
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Error Handler Class
gumbo_load ("Interface_Error_Handler");
* Catches an Error triggered by the program
* @param int|Exception$errno Error code (trigger_error), Exception object
* @param string $errstr Error message, Exception class name
* @param string $errfile location of Error occurence
* @param int $errline line number Error occured
* @param string $errfunc function or class::method where error occured
* @uses Gumbo_Exception, Gumbo_Error
public static function trigger ($errno, $errstr=
null, $errfile=
null, $errline=
null, $errfunc=
null) {
gumbo_load ("Exception");
if (is_object ($errno) &&
!($errno instanceof
Exception)) { $errno =
null; }
if (!is_null ($errline) &&
!is_int ($errline)) { $errline =
null; }
if ($errno instanceof
Exception) {
// recieved error through trigger_error() function
if (gumbo_load ($errstr) ||
class_exists ($errstr, false)) {
$err =
new $errstr (null, $errno, $errfile, $errline, $errfunc);
$err =
new $errstr (null, $errno, $errfile, $errline);
$err =
new Gumbo_Exception ($errstr, $errno, $errfile, $errline, $errfunc);
if (!($err instanceof
Exception)) {
$err =
new Gumbo_Exception ("Unkown Error Occured", $errno, $errfile, $errline, $errfunc);
// submit error to the Error class
* Activates this class as the system Error Handler to the trigger method
* Restores the system Error Handlers
* @postcondition restore_error_handler ()
* @postcondition restore_exception_handler ()
public static function reset () {