Пример #1
0
 /**
  * Creates a new translated exception.
  *
  *     throw new Kohana_Exception('Something went terrible wrong, :user',
  *         array(':user' => $user));
  *
  * @param   string|array   status message, custom content to display with error.
  *                         Can also be an array with the "error" message and the "field" name.
  * @param   array          translation variables
  * @param   integer        the http status code
  * @return  void
  */
 public function __construct($message = NULL, array $variables = NULL, Exception $previous = NULL)
 {
     if (is_array($message)) {
         $this->_field = $message['field'];
         $message = $message['error'];
     }
     parent::__construct($message, $variables, $previous);
 }
Пример #2
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  *
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  *
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         $response = Request::factory(Route::get('default')->uri(array('controller' => 'Errors', 'action' => 'index')))->execute();
         $response->status($this->getCode());
         return $response;
     }
 }
Пример #3
0
 public function get_response()
 {
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         return parent::get_response();
     } else {
         $view = View::factory('templates/errors/default');
         $view->set('title', 'Произошла ошибка');
         $view->set('message', "({$this->getCode()}) {$this->getMessage()}");
         $response = Response::factory()->status($this->getCode())->body($view->render());
         return $response;
     }
 }
Пример #4
0
 /**
  * NegoCore HTTP Error handler
  *
  * @return Response
  */
 public function get_response()
 {
     if (Kohana::$environment == Kohana::DEVELOPMENT) {
         return parent::get_response();
     } else {
         $params = array('code' => $this->getCode(), 'message' => rawurlencode($this->getMessage()));
         try {
             $request = Request::factory(Route::get('error')->uri($params), array(), false)->execute()->send_headers(true)->body();
             return Response::factory()->status($this->getCode())->body($request);
         } catch (Exception $e) {
             return parent::get_response();
         }
     }
 }
Пример #5
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  * 
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  * 
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     $params = array('code' => 500, 'message' => rawurlencode($this->getMessage()), 'response' => NULL);
     if ($this instanceof HTTP_Exception) {
         $params['code'] = $this->getCode();
     }
     try {
         return json_encode($params);
     } catch (Exception $e) {
         return parent::get_response();
     }
 }
Пример #6
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  *
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  *
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         // Generate a nicer looking "Oops" page.
         $view = View::factory('error/default');
         $response = Response::factory()->status($this->getCode())->body($view->render());
         return $response;
     }
 }
Пример #7
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  * 
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  * 
  * @return Response
  */
 public function get_response()
 {
     if (Kohana::$environment === Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         //not saving 404 as error
         if ($this->getCode() != 404) {
             Kohana::$log->add(Log::ERROR, parent::text($this));
         }
         // Generate a nicer looking "Oops" page.
         $view = View::factory('pages/error/default', array('message' => $this->getMessage()));
         $response = Response::factory()->status($this->getCode())->body($view->render());
         return $response;
     }
 }
Пример #8
0
 /**
  * Run CSRF check and load frontend assets.
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     }
     $response = Response::factory();
     $assets = Kohana::$config->load('assets.global');
     $this->_load_assets($assets);
     $view = new View_Error();
     $view->title = $this->getCode();
     $view->message = $this->getMessage();
     $renderer = Kostache_Layout::factory();
     $response->body($renderer->render($view));
     return $response;
 }
Пример #9
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  *
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         $attributes = ['action' => 500];
         // Get error code as action name
         if ($this instanceof HTTP_Exception) {
             $attributes['action'] = $this->getCode();
             $attributes['message'] = $this->getMessage();
         }
         // Execute the query, addressed to the router for error handling
         return Request::factory(Route::get('error')->uri($attributes))->execute();
     }
 }
Пример #10
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  * 
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  * 
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Config::get('site', 'debug') == Config::YES) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         $params = array('code' => 500, 'message' => rawurlencode($this->getMessage()));
         if ($this instanceof HTTP_Exception) {
             $params['code'] = $this->getCode();
         }
         try {
             $request = Request::factory(Route::get('error')->uri($params), array(), FALSE)->execute()->send_headers(TRUE)->body();
             return Response::factory()->status($this->getCode())->body($request);
         } catch (Exception $e) {
             return parent::get_response();
         }
     }
 }
Пример #11
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  *
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  *
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         // Generate a nicer looking "Oops" page.
         // Get tpl directory
         $front_tpl_dir = Cms_Helper::settings('front_tpl_dir');
         // Get file
         $content_file = Tpl::get_file('default', $front_tpl_dir . '/error');
         // Set variable and render
         $content = Tpl::factory($content_file)->set('code', $this->getCode())->set('message', $this->getMessage())->set('request_url', URL::site(Request::current()->url(), "http"))->render();
         // Factory response
         $response = Response::factory();
         $response->body($content);
         return $response;
     }
 }
Пример #12
0
 /**
  * Generate a Response for all Exceptions without a more specific override
  * 
  * The user should see a nice error page, however, if we are in development
  * mode we should show the normal Kohana error page.
  * 
  * @return Response
  */
 public function get_response()
 {
     // Lets log the Exception, Just in case it's important!
     Kohana_Exception::log($this);
     if (Kohana::$environment >= Kohana::DEVELOPMENT) {
         // Show the normal Kohana error page.
         return parent::get_response();
     } else {
         $view = View::factory('errors/default');
         $view->error_code = $this->getCode();
         $view->message = $this->getMessage();
         $template = View::factory('blank');
         $system_settings = ORM::factory('Systemsetting')->where('name', 'IN', array('language'))->find_all()->as_array('name', 'value');
         $template->title = $this->getMessage();
         $template->meta_description = $this->getMessage();
         $template->meta_keywords = "";
         $template->head_style = "";
         $template->html_lang = $system_settings['language'];
         $template->content = $view->render();
         $response = Response::factory()->status($this->getCode())->body($template->render());
         return $response;
     }
 }
Пример #13
0
 /**
  * Generate a Response for the current Exception
  *
  * @uses   Kohana_Exception::response()
  * @return Response
  */
 public function get_response()
 {
     $response = parent::get_response();
     $this->add_cors_headers($response);
     return $response;
 }