Conditions | 3 |
Paths | 3 |
Total Lines | 27 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public static function get(?\Throwable $exception = null): ?\Throwable |
||
15 | { |
||
16 | // Regular Exception, nothing further to do |
||
17 | |||
18 | if ($exception instanceof \Throwable) { |
||
19 | return $exception; |
||
20 | } |
||
21 | |||
22 | // A regular Error: create an ErrorException |
||
23 | // There is already a sys to convert and Error to ErrorException, so in theory we should never arrive here. |
||
24 | |||
25 | $last_error = \error_get_last(); |
||
26 | |||
27 | if ($last_error) { |
||
28 | return new \ErrorException( |
||
29 | $last_error['message'], // message |
||
30 | 0, // code |
||
31 | $last_error['type'], // severity |
||
32 | $last_error['file'], // filename |
||
33 | $last_error['line'], // lineno |
||
34 | null, // previous |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | // No error |
||
39 | |||
40 | return null; |
||
41 | } |
||
43 |