예제 #1
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);
 }