blob: fd92b356cb399c01d8ea95b65abb33dd8c9cecc6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
namespace Trails;
/**
* @author mlunzena
* @copyright (c) Authors
* @version $Id: trails.php 7001 2008-04-04 11:20:27Z mlunzena $
*/
class Exception extends \Exception
{
protected array $headers;
/**
* @param int $status the status code to be set in the response
* @param string|null $reason a human readable presentation of the status code
* @param array $headers a hash of additional headers to be set in the response
*/
public function __construct(int $status = 500, string $reason = null, array $headers = [])
{
parent::__construct(
$reason ?? Response::get_reason($status),
$status
);
$this->setHeaders($headers);
}
public function setHeaders(array $headers): void
{
$this->headers = $headers;
}
public function getHeaders(): array
{
return $this->headers;
}
public function __toString(): string
{
return "{$this->code} {$this->message}";
}
}
|