8 class Exception
extends \Exception
11 * Exception constructor with reversed arguments
13 * @param int $code HTTP code
14 * @param string $message reason message
16 function __construct(int $code, ?
string $message = null) {
17 parent
::__construct($message, $code);
21 * Construct an Exception from error_get_last()'s message and code 500
24 static function fromLastError() : Exception
{
25 return new static(500, error_get_last()["message"]);
29 * Send the error response
30 * @param Response $res
32 function send(Response
$res) : void
{
33 $res->setResponseCode($this->code
);
34 $res->setBody(new Body
);
35 $res->getBody()->append($this->message
);