Skip to content

Commit

Permalink
Handle Fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
christopheg authored May 26, 2021
1 parent 6c3367d commit bd34cf5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/Skeleton/Error/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ public function register() {
$this->add_handler(new Handler\BasicOutput());
}

register_shutdown_function([$this, 'handle_shutdown']);
set_error_handler([$this, 'handle_error']);
set_exception_handler([$this, 'handle_exception']);
register_shutdown_function([$this, 'handle_shutdown']);

$this->is_registered = true;
}
Expand Down Expand Up @@ -197,8 +197,10 @@ public function handle_shutdown() {
if ($this->is_registered === false) {
return;
}

// Do something useful here.
$error = error_get_last();
if ($error !== null) {
$this->handle_exception(new \ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']));
}
}

/**
Expand Down

0 comments on commit bd34cf5

Please sign in to comment.