コード例 #1
0
ファイル: Restler.php プロジェクト: emildev35/processmaker
 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 = Util::initialize($className);
             $obj->{$method}();
             $handled = true;
         }
     }
     if ($handled) {
         return;
     }
     if (!isset($this->responseFormat)) {
         $this->responseFormat = Util::initialize('JsonFormat');
     }
     $this->composeHeaders($exception);
     /**
      * @var iCompose Default Composer
      */
     $compose = Util::initialize(Defaults::$composeClass, isset($this->apiMethodInfo->metadata) ? $this->apiMethodInfo->metadata : null);
     $this->responseData = $this->responseFormat->encode($compose->message($exception), !$this->productionMode);
     $this->respond();
 }