/** * Set Error * * @param RestfulApiException $exception Exception * * @return Response Response */ public function setError(RestfulApiException $exception) { $body = ['error' => ['message' => $exception->getMessage()]]; if ($exception->hasErrors()) { $body['error']['errors'] = $exception->getErrors(); } if (\Craft\craft()->config->get('devMode', 'restfulApi')) { if ($exception->hasInput()) { $body['error']['input'] = $exception->getInput(); } $body['error']['debug'] = $exception->getTrace(); } $this->transformer = \Craft\craft()->config->get('exceptionTransformer', 'restfulApi'); $this->item = $body; return $this; }