Beispiel #1
0
 public static function factory($status, $message = null, array $variables = array(), Exception $previous = NULL)
 {
     if (empty(Response::$messages[$status])) {
         throw new Kohana_Exception('Undefined status `:status`.', array(':status' => $status));
     }
     $path = strtr(Rest_Exception::$_messages_path, array(':status' => $status));
     $processed_message = Kohana::message($path, $message);
     if (empty($processed_message)) {
         throw new Kohana_Exception('Trying to throw ":message" HTTP_Exception but is not declared in `:path`.', array(':message' => $message, ':path' => 'messages/' . $path));
     }
     ORM::factory('Rest_Log')->add('EXCEPTION/STATUS/' . $status, array('message' => $processed_message));
     $processed_message .= '; more_info: :more_info';
     $variables = array_merge(array(':more_info' => Rest_Exception::get_more_info_link($status, $message)), $variables);
     return Kohana::$errors ? HTTP_Exception::factory($status, $processed_message, $variables) : new Rest_Exception($processed_message, $variables, $previous, $status);
 }