Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHttpException.php
More file actions
Latest commit
63 lines (55 loc) · 1.47 KB
/
Copy pathHttpException.php
File metadata and controls
63 lines (55 loc) · 1.47 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
59
60
61
62
63
<?php
namespaceTraderInteractive;
useException;
/**
* Exception to throw when an http status code should be included.
*
* Defaults to a 500 error.
*/
finalclass HttpException extends Exception
{
private$httpStatusCode;
private$userMessage;
/**
* Constructs
*
* @param string $message @see Exception::__construct()
* @param int $httpStatusCode a valid http status code
* @param int $code @see Exception::__construct()
* @param Exception $previous @see Exception::__construct()
* @param string|null $userMessage a nicer message to display to the user sans sensitive details
*/
publicfunction__construct(
string$message = 'Application Error',
int$httpStatusCode = 500,
int$code = 0,
Exception$previous = null,
string$userMessage = null
) {
parent::__construct($message, $code, $previous);
$this->httpStatusCode = $httpStatusCode;
if ($userMessage !== null) {
$this->userMessage = $userMessage;
} else {
$this->userMessage = $message;
}
}
/**
* Getter for $httpStatusCode
*
* @return int the http status code
*/
publicfunctiongetHttpStatusCode() : int
{
return$this->httpStatusCode;
}
/**
* Getter for $userMessage
*
* @return string the user message
*/
publicfunctiongetUserMessage() : string
{
return$this->userMessage;
}
}