Lib/Error/SerializerExceptionRenderer.php
protected function renderCakeAsJson(CakeException $error) {
		// Set the view class as json and render as json
		$this->controller->viewClass = 'Json';
		$this->controller->response->type('json');

		$url = $this->controller->request->here();
		$code = ($error->getCode() >= 400 && $error->getCode() < 506) ? $error->getCode() : 500;
		$this->controller->response->statusCode($code);
		$this->controller->set(array(
			'code' => $code,
			'name' => h(get_class($error)),
			'message' => h($error->getMessage()),
			'url' => h($url),
			'error' => $error,
			'_serialize' => array('code', 'name', 'message', 'url')
		));
		$this->controller->set($error->getAttributes());
		$this->_outputMessage($this->template);
	}
protected function renderCakeAsJson(CakeException $error) {
		// Set the view class as json and render as json
		$this->controller->viewClass = 'Json';
		$this->controller->response->type('json');

		$url = $this->controller->request->here();
		$code = ($error->getCode() >= 400 && $error->getCode() < 506) ? $error->getCode() : 500;
		$this->controller->response->statusCode($code);
		$this->controller->set(array(
			'code' => $code,
			'name' => h(get_class($error)),
			'message' => h($error->getMessage()),
			'url' => h($url),
			'error' => $error,
			'_serialize' => array('code', 'name', 'message', 'url')
		));
		$this->controller->set($error->getAttributes());
		$this->_outputMessage($this->template);
	}
render the CakeException for a JSON request

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