Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using custom error handler #999

Closed
jtojnar opened this issue Feb 16, 2017 · 2 comments
Closed

Allow using custom error handler #999

jtojnar opened this issue Feb 16, 2017 · 2 comments
Labels

Comments

@jtojnar
Copy link

jtojnar commented Feb 16, 2017

I would like to use Tracy for handling errors and exceptions since it has interesting features like AJAX error handling.

@Rayne
Copy link
Contributor

Rayne commented Feb 16, 2017

Fat-Free Framework doesn't forbid to use a third party debugger or error handler. I did a few successful tests with a custom ONERROR handler which forwards the errors to Tracy.

Two notes:

  • I didn't test the AJAX part
  • The snippet is using the public method Debugger::exceptionHandler which is declared as @internal.
$f3->set('ONERROR', function () use ($f3) {
    Debugger::barDump($f3->get('ERROR'), 'ERROR');
    $e = $f3->get('EXCEPTION');
    // There isn't an exception when calling `Base->error()`.
    if (!$e instanceof Throwable) {
        $e = new Exception('HTTP ' . $f3->get('ERROR.code'));
    }
    Debugger::exceptionHandler($e);
});

Full example: Fat-Free Framework with PHP Debugger Tracy

@ikkez ikkez added the question label Feb 19, 2019
@ikkez ikkez closed this as completed Feb 19, 2019
@jtojnar
Copy link
Author

jtojnar commented Dec 15, 2020

The issue with using ONERROR is precisely that it requires us to connect fatfree with whatever handler we want manually, rather than just using the other library’s defaults.

Additionally, even if we set ONERROR handler, fatfree still changes the HTTP status code, spams the stderr with error_log function and then dies, even though we might want to avoid any of that.

jtojnar added a commit to fossar/selfoss that referenced this issue Dec 15, 2020
Trying to access non-existent array fields is a warning in PHP 8.

Also, Dice uses `ReflectionParameter::getClass()`, which is deprecated in PHP 8. Since we have not yet set an error handler at that point because it needs a `Logger` class instantiated by Dice, let’s disable deprecation warnings temporarily. Unfortunately, we cannot just re-enable them and log them in the error handler since fatfree’s error handler is extremely inflexible bcosca/fatfree#999.
jtojnar added a commit to fossar/selfoss that referenced this issue Dec 16, 2020
Trying to access non-existent array fields is a warning in PHP 8.
Though this error is masked by ddeboer/transcoder#5 in the integration tests when mbstring extension is available.

Also, Dice uses `ReflectionParameter::getClass()`, which is deprecated in PHP 8. Since we have not yet set an error handler at that point because it needs a `Logger` class instantiated by Dice, let’s disable deprecation warnings temporarily. Unfortunately, we cannot just re-enable them and log them in the error handler since fatfree’s error handler is extremely inflexible bcosca/fatfree#999.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants