当前位置: 首页>>代码示例>>PHP>>正文


PHP Kohana_Exception::_handler方法代码示例

本文整理汇总了PHP中Kohana_Exception::_handler方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana_Exception::_handler方法的具体用法?PHP Kohana_Exception::_handler怎么用?PHP Kohana_Exception::_handler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kohana_Exception的用法示例。


在下文中一共展示了Kohana_Exception::_handler方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handler

 /**
  * Inline exception handler, displays the error message, source of the
  * exception, and the stack trace of the error.
  *
  * @uses    Kohana_Exception::response
  * @param   Exception  $e
  * @return  void
  */
 public static function handler(Exception $e)
 {
     $response = Kohana_Exception::_handler($e);
     // Send the response to the browser
     echo $response->send_headers()->body();
     exit(1);
 }
开发者ID:EhteshamMehmood,项目名称:BlogMVC,代码行数:15,代码来源:Exception.php

示例2: handler

 public static function handler(Exception $e)
 {
     $response = Kohana_Exception::_handler($e);
     $html_response = $response->send_headers()->body();
     // --- email ------------------------------------------------------------------------------
     // Отправка почты
     $config = Kohana::$config->load('email');
     //var_dump(Email);
     //$to = $config['options']['callback_email'];
     $to = 'chernogolovka@list.ru';
     //$to = 'chernogolovka@list.ru';
     $subject = 'Ошибка на ' . Kohana::$base_url;
     $from = 'admin@oi66.ru';
     $message = $html_response;
     $headers = "MIME-Version: 1.0\r\n";
     $headers .= "Content-type: text/html; charset=charset=UTF-8\r\n";
     $headers .= "From: Error Handler <" . $from . ">\r\n";
     //mail($to, $subject, $message, $headers);
     // --- /email -----------------------------------------------------------------------------
     // Send the response to the browser
     echo $html_response;
     exit(1);
 }
开发者ID:chernogolov,项目名称:blank,代码行数:23,代码来源:Exception.php

示例3: execute_request

 public function execute_request(Request $request, Response $response)
 {
     // Create the class prefix
     $prefix = 'Controller_';
     // Directory
     $directory = $request->directory();
     // Controller
     $controller = $request->controller();
     if ($directory) {
         // Add the directory name to the class prefix
         $prefix .= str_replace(array('\\', '/'), '_', trim($directory, '/')) . '_';
     }
     if (Kohana::$profiling) {
         // Set the benchmark name
         $benchmark = '"' . $request->uri() . '"';
         if ($request !== Request::$initial and Request::$current) {
             // Add the parent request uri
             $benchmark .= ' « "' . Request::$current->uri() . '"';
         }
         // Start benchmarking
         $benchmark = Profiler::start('Requests', $benchmark);
     }
     // Store the currently active request
     $previous = Request::$current;
     // Change the current request to this request
     Request::$current = $request;
     // Is this the initial request
     $initial_request = $request === Request::$initial;
     try {
         if (!class_exists($prefix . $controller)) {
             $prefix = str_replace('_', '\\', $prefix);
             $controller = str_replace('_', '\\', $controller);
             if (!class_exists($prefix . $controller)) {
                 $z = new HTTP_Exception_404('The requested URL :uri was not found on this server.at :prefix :controller', array(':uri' => $request->uri(), ':prefix' => $prefix, ':controller' => $controller));
                 $z->request($request);
                 throw $z;
             }
         }
         // Load the controller using reflection
         $class = new ReflectionClass($prefix . $controller);
         if ($class->isAbstract()) {
             throw new Kohana_Exception('Cannot create instances of abstract :controller', array(':controller' => $prefix . $controller));
         }
         // Create a new instance of the controller
         $controller = $class->newInstance($request, $response);
         // Run the controller's execute() method
         $response = $class->getMethod('execute')->invoke($controller);
         if (!$response instanceof Response) {
             // Controller failed to return a Response.
             throw new Kohana_Exception('Controller failed to return a Response');
         }
     } catch (HTTP_Exception $e) {
         // Store the request context in the Exception
         if ($e->request() === NULL) {
             $e->request($request);
         }
         // Get the response via the Exception
         $response = $e->get_response();
     } catch (Exception $e) {
         // Generate an appropriate Response object
         $response = Kohana_Exception::_handler($e);
     }
     // Restore the previous request
     Request::$current = $previous;
     if (isset($benchmark)) {
         // Stop the benchmark
         Profiler::stop($benchmark);
     }
     // Return the response
     return $response;
 }
开发者ID:astar3086,项目名称:studio_logistic,代码行数:71,代码来源:Internal.php

示例4: __toString

 /**
  * Magic method, returns the output of [View::render].
  *
  * @return  string
  * @uses    View::render
  */
 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         /**
          * Display the exception message.
          *
          * We use this method here because it's impossible to throw an
          * exception from __toString().
          */
         $error_response = Kohana_Exception::_handler($e);
         return $error_response->body();
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:21,代码来源:View.php


注:本文中的Kohana_Exception::_handler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。