Skip to content

Fix missing scope information on unhandled exceptions #611

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

Merged
merged 2 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- Fix missing scope information on unhandled exceptions (#611)

## 3.1.0

- Unhandled exceptions are now correctly marked as `handled: false` and displayed as such on the issues list and detail page (#608)
Expand Down
12 changes: 1 addition & 11 deletions src/Sentry/Laravel/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,10 @@ public static function sentryBaggageMeta(): string
*/
public static function captureUnhandledException(Throwable $throwable): ?EventId
{
$client = SentrySdk::getCurrentHub()->getClient();

// When Sentry is not configured, because for example no DSN
// is set the client can be null. If that is the case we cannot
// transmit the event so, exit early to prevent doing useless work
if ($client === null) {
return null;
}

$hint = EventHint::fromArray([
'exception' => $throwable,
'mechanism' => new ExceptionMechanism(ExceptionMechanism::TYPE_GENERIC, false),
]);

return $client->captureEvent(Event::createEvent(), $hint);
return SentrySdk::getCurrentHub()->captureException($throwable, $hint);
}
}