aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/HttpResponseStatus/InternalServerError.php
blob: 11b67f37762080f1c8e6c8b2899bf3ad73dce0c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
namespace WpfTest\HttpResponseStatus;

use WpfTest\GlobalConfig;
use WpfTest\HttpResponseStatus;

class InternalServerError extends \Exception implements HttpResponseStatus {
    public function __construct(\Throwable $reason, ?string $context = null) {
        $this->message = $reason::class . ': ' . $reason->getMessage();
        if (isset($context)) {
            $this->message .= " [$context]";
        }
        if (GlobalConfig::getInstance()->shouldReportTraces()) {
            $this->message .= "\n" . $reason->getTraceAsString();
        }
    }
    public function httpCode(): int {
        return 500;
    }
    public function httpReason(): string {
        return "Internal Server Error";
    }
}