Beispiel #1
0
 /**
  * Wraps an exception inside a throwable
  *
  * @param  lang.Throwable|php.Throwable|php.Exception $e
  * @return self
  * @throws lang.IllegalArgumentException
  */
 public static function wrap($e) : self
 {
     if ($e instanceof self) {
         return $e;
     } else {
         if ($e instanceof \Exception) {
             $wrapped = new XPException($e->getMessage(), $e->getPrevious(), false);
             $wrapped->addStackTraceFor($e->getFile(), '<native>', get_class($e), $e->getLine(), [$e->getCode(), $e->getMessage()], [['' => 1]]);
             $wrapped->fillInStackTrace($e);
             return $wrapped;
         } else {
             if ($e instanceof \Throwable) {
                 $wrapped = new Error($e->getMessage(), $e->getPrevious(), false);
                 $wrapped->addStackTraceFor($e->getFile(), '<native>', get_class($e), $e->getLine(), [$e->getCode(), $e->getMessage()], [['' => 1]]);
                 $wrapped->fillInStackTrace($e);
                 return $wrapped;
             } else {
                 throw new IllegalArgumentException('Given argument must be a lang.Throwable or a PHP base exception');
             }
         }
     }
 }
 /**
  * Constructor
  *
  * @param  lang.Throwable $reason
  */
 public function __construct($reason)
 {
     parent::__construct($reason->compoundMessage());
 }