Advertisement
fruffl

Untitled

Jul 30th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1.         public function __construct()
  2.         {
  3.             static::$__flag = (~0)<<static::__MASK;
  4.             static::$__mask = ~static::$__flag;
  5.            
  6.             static::$__catchError =
  7.             [
  8.                 "#failed to open stream#" =>
  9.                 [
  10.                     'msg'   => "IO::Failed to open stream with",
  11.                     'code'  => 1<<static::IO_READ | 1<<static::ILLI_EXIT
  12.                 ],
  13.                 "#Filename cannot be empty#" =>
  14.                 [
  15.                     'msg'   => "Filename cannot be empty",
  16.                     'code'  => 1<<static::IO_PATH_EMPTY | 1<<static::ILLI_EXIT
  17.                 ],
  18.                 "#open_basedir#" =>
  19.                 [
  20.                     'msg'   => "Access denied",
  21.                     'code'  => 1<<static::IO_OPEN_BASE | 1<<static::ILLI_EXIT
  22.                 ]
  23.                 ];
  24.            
  25.             set_error_handler( array( __CLASS__, 'e' ) );
  26.             register_shutdown_function( array( __CLASS__, 'e' ) );
  27.         }
  28.        
  29.         public static function e($errno = 0, $errstr = 'unknown', $errfile = 'unknown', $errline = 'NaN', $context = NULL)
  30.         {
  31.                     if($errno === 0)
  32.                         return FALSE;
  33.                    
  34.                 foreach (static::$__catchError as $regexp => $res)
  35.                     if(preg_match($regexp,$errstr,$match))
  36.                             throw new \Exception($res['msg']."\n\n".$errstr, $res['code']|( $errno & static::__MASK));
  37.                        
  38.                     throw new \Exception($errstr, ( $errno & static::__MASK ) );
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement