Skip to content

Commit f764225

Browse files
rbnmulderRobin Mulder
andauthored
Check if there is a hint exception defined (#3)
Co-authored-by: Robin Mulder <robin@justbetter.nl>
1 parent 2d8a192 commit f764225

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Observer/BeforeSending.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function execute(Observer $observer): void
3030
$event = $observer->getEvent()->getSentryEvent()->getEvent();
3131
$hint = $observer->getEvent()->getSentryEvent()->getHint();
3232

33-
$hintMessage = $hint->exception->getMessage();
34-
if ($hint->exception instanceof LocalizedException) {
33+
$hintMessage = $hint?->exception?->getMessage() ?? $event->getMessage();
34+
if ($hint?->exception instanceof LocalizedException) {
3535
$hintMessage = $hint->exception->getRawMessage();
3636
$event->setMessage($hintMessage);
3737
}
@@ -40,7 +40,9 @@ public function execute(Observer $observer): void
4040
foreach ($messages as $message) {
4141
if (str_contains($hintMessage, $message['message'])) {
4242
$observer->getEvent()->getSentryEvent()->unsEvent();
43+
break;
4344
}
4445
}
46+
4547
}
4648
}

0 commit comments

Comments
 (0)