49 lines
930 B
PHP
49 lines
930 B
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
class ErrorController extends ViewController
|
|
{
|
|
private function sendErrorHeader($statusCode, $view)
|
|
{
|
|
http_response_code($statusCode);
|
|
$this->render($view);
|
|
exit;
|
|
}
|
|
|
|
public function notFound()
|
|
{
|
|
$this->sendErrorHeader(404, 'error/404');
|
|
}
|
|
|
|
public function forbidden()
|
|
{
|
|
$this->sendErrorHeader(403, 'error/403');
|
|
}
|
|
|
|
public function internalServerError()
|
|
{
|
|
$this->sendErrorHeader(500, 'error/500');
|
|
}
|
|
|
|
public function badRequest()
|
|
{
|
|
$this->sendErrorHeader(400, 'error/400');
|
|
}
|
|
|
|
public function unauthorized()
|
|
{
|
|
$this->sendErrorHeader(401, 'error/401');
|
|
}
|
|
|
|
public function requestTimeout()
|
|
{
|
|
$this->sendErrorHeader(408, 'error/408');
|
|
}
|
|
|
|
public function serviceUnavailable()
|
|
{
|
|
$this->sendErrorHeader(503, 'error/503');
|
|
}
|
|
}
|