コード例 #1
0
 /**
  * Generates an error page for a thrown exception which was not caught anywhere else in the code
  * 
  * @param \Exception $e The uncaught exception
  *
  * @return HttpResponse The HTTP response for sending back to the client (e.x. a nice styled error message)
  */
 public function generateErrorPage(\Exception $e)
 {
     $errorCode = 500;
     if ($e instanceof HttpException) {
         $errorCode = $e->getCode();
     }
     if ($e instanceof HttpException === false || $e->getCode() === 500) {
         $this->logger->error('An uncaught error occurred', $e);
     }
     $stmntErrorPage = $this->db->prepare("SELECT ID FROM page WHERE role = 'error' AND error_code = ?");
     $resErrorPage = $this->db->select($stmntErrorPage, array($errorCode));
     $env = $this->currentDomain->environment;
     if ($this->core->getSettings()->core->environments->{$env}->debug === true || count($resErrorPage) <= 0) {
         return parent::generateErrorPage($e);
     }
     $pageModel = new PageModel($this->db);
     $this->cmsPage = $pageModel->getPageByID($resErrorPage[0]->ID);
     return $this->generateCMSPage($pageModel);
 }