Exemple #1
0
 public function __construct($code, array $params = array(), Exception $previous = null)
 {
     $message = isset($this->_messages[$code]) ? $this->_messages[$code] : '';
     $this->_params = $params;
     parent::__construct($message, $code, $previous);
     Logger::exception($this);
 }
Exemple #2
0
 public function error(Exception $error)
 {
     switch ($error->getCode()) {
         case Exception::ROUTER_WRONG_PARAMS:
         case Exception::ROUTER_WRONG_FORMAT:
         case Exception::ROUTER_WRONG_VERSION:
             header($_SERVER["SERVER_PROTOCOL"] . ' 400 Bad Request');
             break;
         case Exception::ROUTER_WRONG_CONTROLLER:
             header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found');
             break;
         case Exception::ROUTER_WRONG_METHOD:
             header($_SERVER["SERVER_PROTOCOL"] . ' 405 Method Not Allowed');
             if ($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];
                 }
                 header('Allow: ' . implode(',', $str));
             }
             break;
     }
 }