Esempio n. 1
0
 /**
  * @param Exception $exception
  */
 public function exception(Exception $exception)
 {
     $this->request = Cordillera::$instance->{'request'};
     $this->controller = Cordillera::$instance->{'controller'};
     $this->config = Cordillera::$instance->{'config'};
     $this->logger = Cordillera::$instance->{'logger'};
     $this->response = Cordillera::$instance->{'response'};
     if ($this->request->isAjax() || isset($this->controller) && ($this->controller->response_type == 'json' || $this->controller->is_rest)) {
         $response = ['error' => true, 'message' => $exception->getMessage()];
         if (CORDILLERA_DEBUG) {
             $response['trace'] = $exception->getAllTraces();
         }
         if ($this->config->get('exception.show_log_id') && $this->logger->last_log_id) {
             $response['log_id'] = logger()->last_log_id;
         }
         $this->response->json($response);
     } else {
         $layout = new Layout('error');
         if (CORDILLERA_DEBUG) {
             $layout->properties['title'] = Exception::$types[$exception->getCode()];
         }
         if (ob_get_length()) {
             ob_end_clean();
         }
         echo $layout->render($exception->toHtml());
     }
     exit;
 }
Esempio n. 2
0
 /**
  * @param string $message
  * @param int    $status_code
  * @param int    $code
  * @param mixed  $previous
  */
 public function __construct($message = '', $status_code = 500, $code = -1, $previous = null)
 {
     parent::__construct($message, $code, $previous);
     app()->response->headerStatus($status_code, false);
 }