-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpException.php
More file actions
58 lines (50 loc) · 1.17 KB
/
HttpException.php
File metadata and controls
58 lines (50 loc) · 1.17 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/*
* Opulence
*
* @link https://www.opulencephp.com
* @copyright Copyright (C) 2021 David Young
* @license https://github.com/opulencephp/Opulence/blob/1.2/LICENSE.md
*/
namespace Opulence\Http;
use Exception;
/**
* Defines an exception that is thrown by an HTTP component
*/
class HttpException extends Exception
{
/** @var int The HTTP status code */
private $statusCode = 200;
/** @var array The list of headers to include */
private $headers = [];
/**
* @inheritdoc
* @param int $statusCode The HTTP status code
* @param array $headers The HTTP headers
*/
public function __construct(
int $statusCode,
string $message = '',
array $headers = [],
int $code = 0,
Exception $previous = null
) {
parent::__construct($message, $code, $previous);
$this->statusCode = $statusCode;
$this->headers = $headers;
}
/**
* @return array
*/
public function getHeaders() : array
{
return $this->headers;
}
/**
* @return int
*/
public function getStatusCode() : int
{
return $this->statusCode;
}
}