public function error(Exception $error) { parent::error($error); header("Content-Type: application/json"); $data = array('success' => 0, 'error' => array('code' => $error->getCode(), 'message' => $error->getMessage())); if ($error->getCode() == Exception::ROUTER_WRONG_METHOD && ($params = $error->getParams())) { $str = array(); $codes = array(Controller::CRUD_CREAT => 'POST', Controller::CRUD_READ => 'GET', Controller::CRUD_UPDATE => 'PUT', Controller::CRUD_DELETE => 'DELETE'); foreach ($params as $v) { $str[] = $codes[$v]; } $data['error']['allow'] = implode(',', $str); } echo json_encode($data); }
public function error(Exception $error) { parent::error($error); header("Content-Type: application/xml"); echo $this->_arrayToXML(array('error' => array('code' => $error->getCode(), 'message' => $error->getMessage()))); }