-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErr.php
36 lines (28 loc) · 846 Bytes
/
Err.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
<?php
namespace Log;
class Err extends Log {
static public function fatal(\Throwable $e, string $name=self::ERR_FATAL, string $prefix_error=''): string{
$error = ($prefix_error ?: '').self::format($e);
if($prev_e = $e->getPrevious()){
$error .= "\nPrevious error: ".self::format($prev_e);
}
self::err($name, $error);
return $error;
}
static public function format(\Throwable $e): string{
return self::trace_format($e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString());
}
static public function catch_all(\Throwable $e){
if(!headers_sent()){
header('Content-Type: text/plain');
}
$error = self::fatal($e);
if(self::is_verbose()){
echo $error;
}
// Show less information in production mode
else{
echo 'Error: '.get_class($e);
}
}
}