예제 #1
0
 protected function message(Exception $exception)
 {
     $this->dispatch('message');
     if (!$exception instanceof RestException) {
         $exception = new RestException(500, $this->productionMode ? null : $exception->getMessage(), array(), $exception);
     }
     $this->exception = $exception;
     $method = 'handle' . $exception->getCode();
     $handled = false;
     foreach ($this->errorClasses as $className) {
         if (method_exists($className, $method)) {
             $obj = Scope::get($className);
             if ($obj->{$method}()) {
                 $handled = true;
             }
         }
     }
     if ($handled) {
         return;
     }
     if (!isset($this->responseFormat)) {
         $this->responseFormat = Scope::get('JsonFormat');
     }
     $this->composeHeaders($exception);
     /**
      * @var iCompose Default Composer
      */
     $compose = Scope::get(Defaults::$composeClass);
     $this->responseData = $this->responseFormat->encode($compose->message($exception), !$this->productionMode);
     $this->respond();
 }
 public function __construct($message)
 {
     parent::__construct(400, $message);
 }
 public function __construct($max_limit)
 {
     parent::__construct(406, 'Limit is out of bounds [1..' . $max_limit . ']');
 }