Exemplo n.º 1
0
 /**
  * Register core exception handler and http status code hanlding.
  * Exception instance can be accessed in errorHandler service.
  *
  * @return \Avenue\App
  */
 protected function registerExceptionHandler()
 {
     set_exception_handler(function (\Exception $exception) {
         $this->exception = $exception;
         $code = $this->exception->getCode();
         $statusCode = $this->response->getStatusCode();
         if (!is_int($code) || $code < 400 || $code > 599) {
             $code = 500;
         }
         // overwrite with user defined
         if ((int) $statusCode >= 400) {
             $code = $statusCode;
         }
         $this->response->withStatus($code);
         $this->resolve('errorHandler');
     });
     return $this;
 }
Exemplo n.º 2
0
 public function testGetAppIDInException()
 {
     $appId = 'testexceptionappid';
     $app = new App(['timezone' => 'UTC'], $appId);
     $exception = new Exception($this->app, new \RuntimeException('yo! I am runtime exception.'));
     $this->assertEquals($appId, $exception->getAppId());
 }
Exemplo n.º 3
0
 /**
  * Get formatted string of trace.
  *
  * @return string
  */
 public function getTraceAsString()
 {
     return $this->exception->getTraceAsString();
 }