Example #1
0
 /**
  * Creates a new translated exception.
  * @param   string   status message, custom content to display with error
  * @param   array    translation variables
  * @param   integer  the http status code
  * @return  void
  */
 public function __construct($message = NULL, array $variables = NULL, $code = 0)
 {
     if ($code == 0) {
         $code = $this->_code;
     }
     //if ( ! isset(Response::$messages[$code]))
     //	throw new K_Exception('Unrecognized HTTP status code: :code . Only valid HTTP status codes are acceptable, see RFC 2616.', array(':code' => $code));
     parent::__construct($message, $variables, $code);
 }
Example #2
0
 /**
  * Inline exception handler, displays the error message, source of the
  * exception, and the stack trace of the error.
  *
  * @uses    Exception_Exception::text
  * @param   object   exception object
  * @return  boolean
  */
 public static function handler(exception $e)
 {
     try {
         // устанавливаем ошибку в контроллер, что бы не рендерил представление
         K_Controller::setError();
         // Get the exception information
         $type = get_class($e);
         $code = $e->getCode();
         $message = $e->getMessage();
         $file = $e->getFile();
         $line = $e->getLine();
         // Get the exception backtrace
         $trace = $e->getTrace();
         if ($e instanceof ErrorException) {
             if (isset(K_Exception::$php_errors[$code])) {
                 // Use the human-readable error name
                 $code = K_Exception::$php_errors[$code];
             }
         }
         // Create a text version of the exception
         $error = K_Exception::text($e);
         if (K_Request::isAjax() === true) {
             // Just display the text of the exception
             echo "\n{$error}\n";
             // добовляем ошибку в логгер и дебагер
             K_Log::get()->add($error);
             K_Debug::get()->add($error, $trace);
             exit(1);
         }
         echo "\n{$error}\n";
         // добовляем ошибку в логгер и дебагер
         K_Log::get()->add($error);
         K_Debug::get()->addError($error, $trace);
         exit(1);
     } catch (exception $e) {
         // Clean the output buffer if one exists
         ob_get_level() and ob_clean();
         // Display the exception text
         echo K_Exception::text($e), "\n";
         // Exit with an error status
         exit(1);
     }
 }