示例#1
0
 protected function renderJson()
 {
     if ($this->response->hasException()) {
         $output = array('exception' => array('message' => $this->response->getException()->getMessage(), 'code' => $this->response->getException()->getCode()));
     } else {
         $output = $this->response->getData();
     }
     return json_encode($output);
 }
示例#2
0
 protected function renderJson()
 {
     if ($this->response->hasException()) {
         $exception = $this->response->getException();
         $output = array('exception' => array('message' => $exception->getMessage(), 'code' => $exception->getCode(), 'details' => ''));
         if (is_callable([$exception, 'getDetails'])) {
             $output['exception']['details'] = $exception->getDetails();
         }
     } else {
         $output = $this->response->getData();
     }
     return json_encode($output);
 }