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

Should not use set_exception_handler #66

Open
jarbey opened this issue Aug 10, 2022 · 3 comments
Open

Should not use set_exception_handler #66

jarbey opened this issue Aug 10, 2022 · 3 comments

Comments

@jarbey
Copy link

jarbey commented Aug 10, 2022

set_exception_handler([ExceptionHandler::getInstance(), 'handle']);

Using set_exception_handler can override existings handler and can be a big problem for application that already use it.
For it has shutdown the NewRelic error reporting !

I suggest either to not use it or, to use it right before a call and call restore_exception_handler after the call (a successfull call or an error one).

I will have to find a way to change that. If i can will propose you a pullrequest

@denpamusic
Copy link
Owner

Thank you for the feedback!

I'll see what I can do to change exception handling on the weekends.
PR would be awesome too!

Sorry for inconvenience that it caused.

@jarbey
Copy link
Author

jarbey commented Aug 11, 2022

Don't be worry for the inconvenience ! I should thank you for the job you have done and to share it with everyone !

I was asking myself "Why an handler is needed ?"

  • As for sync call you already have a try / catch :
    try {
    $response = $this->client
    ->post($this->path, $this->makeJson($method, $params));
    if ($response->hasError()) {
    // throw exception on error
    throw new BadRemoteCallException($response);
    }
    return $response;
    } catch (Throwable $exception) {
    throw exception()->handle($exception);
    }
  • For Async call you manage error on the promise :
    try {
    exception()->handle($exception);
    } catch (Throwable $exception) {
    $this->onError($exception, $rejected);
    }

Maybe it's not usefull to use a global PHP Exception handler, and we can locally trap exception, if there is any missing ?

@jarbey
Copy link
Author

jarbey commented Sep 15, 2022

Any update on that please ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants