File tree Expand file tree Collapse file tree 4 files changed +238
-222
lines changed Expand file tree Collapse file tree 4 files changed +238
-222
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /*
4+ * This file is part of https://github.com/josantonius/php-error-handler repository.
5+ *
6+ * (c) Josantonius <hello@josantonius.dev>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ namespace Josantonius \ErrorHandler ;
13+
14+ use ErrorException as BaseErrorException ;
15+ use Josantonius \ErrorHandler \ErrorHandled ;
16+
17+ class ErrorException extends BaseErrorException
18+ {
19+ protected int $ level ;
20+
21+ protected string $ name ;
22+
23+ public function __construct (ErrorHandled $ errorHandled )
24+ {
25+ $ this ->level = $ errorHandled ->getLevel ();
26+ $ this ->name = $ errorHandled ->getName ();
27+
28+ parent ::__construct (
29+ $ errorHandled ->getMessage (),
30+ 0 ,
31+ $ errorHandled ->getLevel (),
32+ $ errorHandled ->getFile (),
33+ $ errorHandled ->getLine ()
34+ );
35+ }
36+
37+ public function getLevel (): int
38+ {
39+ return $ this ->level ;
40+ }
41+
42+ public function getName (): string
43+ {
44+ return $ this ->name ;
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ /*
6+ * This file is part of https://github.com/josantonius/php-error-handler repository.
7+ *
8+ * (c) Josantonius <hello@josantonius.dev>
9+ *
10+ * For the full copyright and license information, please view the LICENSE
11+ * file that was distributed with this source code.
12+ */
13+
14+ namespace Josantonius \ErrorHandler ;
15+
16+ /**
17+ * Details of the error handled.
18+ */
19+ class ErrorHandled
20+ {
21+ /**
22+ * Sets error details.
23+ */
24+ public function __construct (
25+ private int $ level ,
26+ private string $ message ,
27+ private string $ file ,
28+ private int $ line ,
29+ private string $ name
30+ ) {
31+ }
32+
33+ /**
34+ * Gets error file.
35+ */
36+ public function getFile (): string
37+ {
38+ return $ this ->file ;
39+ }
40+
41+ /**
42+ * Gets error message.
43+ */
44+ public function getMessage (): string
45+ {
46+ return $ this ->message ;
47+ }
48+
49+ /**
50+ * Gets error level.
51+ */
52+ public function getLevel (): int
53+ {
54+ return $ this ->level ;
55+ }
56+
57+ /**
58+ * Gets error file line.
59+ */
60+ public function getLine (): int
61+ {
62+ return $ this ->line ;
63+ }
64+
65+ /**
66+ * Gets error name.
67+ */
68+ public function getName (): string
69+ {
70+ return $ this ->name ;
71+ }
72+ }
You can’t perform that action at this time.
0 commit comments