Lib/Error/SerializerExceptionRenderer.php
protected function renderCakeAsJsonApi(CakeException $error) {
		// Add a response type for JSON API
		$this->controller->response->type(array('jsonapi' => 'application/vnd.api+json'));
		// Set the controller to response as JSON API
		$this->controller->response->type('jsonapi');
		// Set the correct Status Code
		$this->controller->response->statusCode($error->getCode());

		// set the errors object to match JsonApi's standard
		$errors = array(
			'errors' => array(
				'id' => null,
				'href' => null,
				'status' => h($error->getCode()),
				'code' => h(get_class($error)),
				'title' => h($error->getMessage()),
				'detail' => h($error->getAttributes()),
				'links' => array(),
				'paths' => array(),
			),
		);
		// json encode the errors
		$jsonEncodedErrors = json_encode($errors);

		// set the body to the json encoded errors
		$this->controller->response->body($jsonEncodedErrors);
		return $this->controller->response->send();
	}
protected function renderCakeAsJsonApi(CakeException $error) {
		// Add a response type for JSON API
		$this->controller->response->type(array('jsonapi' => 'application/vnd.api+json'));
		// Set the controller to response as JSON API
		$this->controller->response->type('jsonapi');
		// Set the correct Status Code
		$this->controller->response->statusCode($error->getCode());

		// set the errors object to match JsonApi's standard
		$errors = array(
			'errors' => array(
				'id' => null,
				'href' => null,
				'status' => h($error->getCode()),
				'code' => h(get_class($error)),
				'title' => h($error->getMessage()),
				'detail' => h($error->getAttributes()),
				'links' => array(),
				'paths' => array(),
			),
		);
		// json encode the errors
		$jsonEncodedErrors = json_encode($errors);

		// set the body to the json encoded errors
		$this->controller->response->body($jsonEncodedErrors);
		return $this->controller->response->send();
	}
render the CakeException for a JSON API request

@param CakeException $error an instance of CakeException
@return void