Example #1
0
 /**
  * @return void
  */
 public function finish()
 {
     if ($messages = Logger::get('error')) {
         foreach ($messages as $message) {
             errorLog($message);
         }
     }
     // return code 1 for invalid behaviour of application
     if ($exception = Response::getException()) {
         echo $exception->getMessage();
         exit(1);
     }
     exit;
 }
Example #2
0
 /**
  * Assert forbidden
  *
  * @return void
  */
 protected function assertForbidden()
 {
     $exception = Response::getException();
     $this->assertInstanceOf('\\Bluz\\Application\\Exception\\ForbiddenException', $exception);
     $this->assertEquals(403, Response::getStatusCode());
     $this->assertModule(Router::getErrorModule());
     $this->assertController(Router::getErrorController());
 }
Example #3
0
            break;
        default:
            $code = 500;
            $title = __("Internal Server Error");
            $description = __("An unexpected error occurred with your request. Please try again later");
            break;
    }
    // check CLI or HTTP request
    if (Request::isHttp()) {
        // simple AJAX call, accept JSON
        if (Request::getAccept() == Request::ACCEPT_JSON) {
            $this->useJson();
            Messages::addError($description);
            return $view;
        }
        // dialog AJAX call, accept HTML
        if (!Request::isXmlHttpRequest()) {
            $this->useLayout('small.phtml');
        }
    }
    Layout::title($title);
    $view->error = $title;
    $view->description = $description;
    if ($this->isDebug() && ($e = Response::getException()) && $code >= 500) {
        $whoops = new Run();
        $whoops->pushHandler(new PrettyPageHandler());
        $whoops->handleException($e);
        return false;
    }
    return $view;
};