-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathError.php
53 lines (47 loc) · 1.11 KB
/
Error.php
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
<?php declare(strict_types = 1);
namespace noxkiwi\core;
use JetBrains\PhpStorm\Pure;
use Throwable;
/**
* I am an arbitrary Error.
* Class StackOf
* @package noxkiwi\core
*/
class Error extends \Error
{
public const KEY_CODE = 'CODE';
/** @var array I am the Error's detail. */
private array $detail;
/**
* Error constructor.
*
* @param string $message
* @param int $code
* @param \Throwable|null $previous
*/
#[Pure] public function __construct(string $message = '', int $code = 0, Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->detail = [];
}
/**
* I will return the detail array.
* @return array
*/
final public function getDetail(): array
{
return $this->detail;
}
/**
* I will set the detail to the given array.
*
* @param array|null $detail
*
* @return \noxkiwi\core\Error
*/
final public function setDetail(array $detail = null): Error
{
$this->detail = $detail ?? [];
return $this;
}
}