-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add meta data interface and trait #574
Conversation
@@ -275,6 +276,10 @@ public function notifyException($throwable, callable $callback = null) | |||
{ | |||
$report = Report::fromPHPThrowable($this->config, $throwable); | |||
|
|||
if ($throwable instanceof MetaDataAwareInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be implemented by a middleware, rather than being baked into the client like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not that familiar with this SDK. But the middleware doesn't get any exceptions, does it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, that is correct. Maybe we should change the report object to keep the actual exception around, so people can grab it (by means of a method on the report object that returns the exception or null).
@@ -275,6 +276,10 @@ public function notifyException($throwable, callable $callback = null) | |||
{ | |||
$report = Report::fromPHPThrowable($this->config, $throwable); | |||
|
|||
if ($throwable instanceof MetaDataAwareInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, that is correct. Maybe we should change the report object to keep the actual exception around, so people can grab it (by means of a method on the report object that returns the exception or null).
This has now been fixed via bugsnag-php release V3.21.0 We have added support for the getting the original error on which you can attach additional metadata. |
Goal
Provide a very simple way to extend an exception with additional meta data everywhere without further dependencies.
Design
This feature is very pragmatic and straightforward. Similar to PSR Logger, we provide a
MetaDataAwareInterface
and aMetaDataAwareTrait
. The developer can (but must not) extend his Exceptions with the Interface / Trait to add some additional informations:Later just pass your informations:
This implementation does not need any services or heavy structures.
Changeset
Added
Changed
Linked issues
Original PR: bugsnag/bugsnag-symfony#83
Review
For the submitter, initial self-review:
For the pull request reviewer(s), this changeset has been reviewed for: