Ejemplo n.º 1
0
 public function render($exception)
 {
     if (\Mii::$app->has('response')) {
         $response = \Mii::$app->response;
     } else {
         $response = new Response();
     }
     if ($this->route && $response->format === Response::FORMAT_HTML && !config('debug')) {
         \Mii::$app->request->execute($this->route)->send();
         return;
     } elseif ($response->format === Response::FORMAT_HTML) {
         if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest') {
             $response->content('<pre>' . e(Exception::text($exception)) . '</pre>');
         } else {
             $params = ['class' => get_class($exception), 'code' => $exception->getCode(), 'message' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'trace' => $exception->getTrace()];
             $response->content($this->render_file(__DIR__ . '/Exception/error.php', $params));
         }
     } else {
         $response->content(Exception::text($exception));
     }
     if ($exception instanceof HttpException) {
         $response->status($exception->status_code);
     } else {
         $response->status(500);
     }
     $response->send();
 }
Ejemplo n.º 2
0
 public function __construct($message = "", array $variables = NULL, $code = 0)
 {
     parent::__construct($message, $variables, $code);
 }
Ejemplo n.º 3
0
 /**
  * Render the current image.
  *
  *     echo $image;
  *
  * [!!] The output of this function is binary and must be rendered with the
  * appropriate Content-Type header or it will not be displayed correctly!
  *
  * @return  string
  */
 public function __toString()
 {
     try {
         // Render the current image
         return $this->render();
     } catch (\Exception $e) {
         // Get the text of the exception
         $error = Exception::text($e);
         \Mii::error($error);
         // Showing any kind of error will be "inside" image data
         return '';
     }
 }