Ejemplo n.º 1
0
 public function testExceptionResolverError()
 {
     $exceptionResolver = new ExceptionResolver();
     $fn = function () {
     };
     $this->setExpectedException('Tier\\TierException');
     $exceptionResolver->addExceptionHandler('FooException', $fn, -10);
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo 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);
     }
 }