Exemplo n.º 1
0
 /**
  * Actually handle the exception.
  * @param $exception
  */
 private function processException($exception)
 {
     Tier::clearOutputBuffer();
     //TODO - we are now failing. Replace error handler with instant
     //shutdown handler.
     $fallBackHandler = ['Tier\\Tier', 'processException'];
     if (class_exists('\\Throwable') === true) {
         $fallBackHandler = ['Tier\\Tier', 'processThrowable'];
     }
     $handler = $this->exceptionResolver->getExceptionHandler($exception, $fallBackHandler);
     try {
         call_user_func($handler, $exception);
     } catch (\Exception $e) {
         Tier::clearOutputBuffer();
         // The exception handler function also threw? Just exit.
         //Fatal error shutdown
         echo $e->getMessage();
         exit(-1);
     } catch (\Throwable $e) {
         Tier::clearOutputBuffer();
         //Fatal error shutdown
         echo $e->getMessage();
         exit(-1);
     }
 }
Exemplo n.º 2
0
 public function testExceptionResolver()
 {
     $exceptionResolver = new ExceptionResolver();
     $fn = function () {
         return "Foo handler";
     };
     $defaultHandler = function () {
         return "Default handler";
     };
     $exceptionResolver->addExceptionHandler('FooException', $fn, 10);
     $exceptionResolver->addExceptionHandler('Fixtures\\FooException', $fn, ExceptionResolver::ORDER_LAST);
     $fooException = new FooException();
     $handler = $exceptionResolver->getExceptionHandler($fooException, $defaultHandler);
     $this->assertEquals("Foo handler", $handler());
     $barException = new BarException();
     $handler = $exceptionResolver->getExceptionHandler($barException, $defaultHandler);
     $this->assertEquals("Default handler", $handler());
 }
Exemplo n.º 3
0
 /**
  * @param Request $request
  */
 public function execute(Request $request)
 {
     try {
         $this->injector->alias('Room11\\HTTP\\Request', get_class($request));
         $this->injector->share($request);
         $this->executeInternal();
     } catch (\Exception $e) {
         list($handler, $exceptionClass) = $this->exceptionResolver->getExceptionHandler($e, 'processException');
         $injector = clone $this->injector;
         if (strcasecmp($exceptionClass, get_class($e)) !== 0) {
             $injector->alias($exceptionClass, get_class($e));
         }
         $injector->share($e);
         $injector->execute($handler);
     }
 }