예제 #1
0
 /**
  * Constructor.
  *
  * @param string    $message  Message of the exception
  * @param int       $code     Error-code of the exception
  * @param Exception $previous Previous thrown exception which should be repacked
  *
  * @author Benjamin Carl <*****@*****.**>
  * @access public
  */
 public function __construct($message = null, $code = 0, Exception $previous = null)
 {
     parent::__construct($message, $code, $previous);
 }
예제 #2
0
 /**
  * Constructor.
  *
  * @param string|null    $message           Message
  * @param int            $code              Code of the exception
  * @param Exception|null $previousException Previously thrown exception - AS_OF: PHP 5.3 introduced!
  *
  * @author Benjamin Carl <*****@*****.**>
  */
 public function __construct($message = null, $code = 0, $previousException = null)
 {
     // Add prefix to message ...
     $message = sprintf('%s: %s', get_class($this), $message);
     // Get final code
     $code = $this->generateUniqueCode($this->file, $code);
     // Dispatch to parent
     parent::__construct($message, $code, $previousException);
 }
예제 #3
0
 /**
  * Replacement for PHP's default internal error handler.
  * All Errors are dispatched to this method - we decide
  * here what to do with it. We need this hook to stay
  * informed about Doozr's state and to pipe the Errors
  * to attached Logger-Subsystem.
  *
  * @param int|string $number  Number of Error (constant)
  * @param string     $message Error description as String
  * @param string     $file    File in which the error occurred
  * @param int        $line    Line in which the error occurred
  * @param array      $context The variables with name and value from error context
  *
  * @throws Doozr_Error_Exception
  * @author Benjamin Carl <*****@*****.**>
  * @return bool TRUE always
  * @access public
  * @static
  */
 public static function handle($number = '', $message = '', $file = '', $line = 0, $context = [])
 {
     // If we shouldn't care we follow this rule!
     if (!($number & error_reporting())) {
         return true;
     }
     // get error type
     $type = self::getErrorType($number);
     // Pack error into an exception so that the error can be forwarded to exception handler
     $error = new Doozr_Exception($message, $number);
     $error->type($type)->message($message)->file($file)->line($line);
     // Now dispatch the error processable and from userland catchable as Exception
     throw new Doozr_Error_Exception($message, $number, $error);
 }