Skip to content

Commit

Permalink
Expect exceptions in MessengerInstrumentation (#238)
Browse files Browse the repository at this point in the history
* Expect exceptions in MessengerInstrumentation

* Rectify wrong import
  • Loading branch information
cedricziel authored Feb 15, 2024
1 parent 9e25568 commit 5ef0ba0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public static function register(): void
post: static function (
MessageBusInterface $bus,
array $params,
Envelope $result,
?Envelope $result,
?\Throwable $exception
): void {
$scope = Context::storage()->scope();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,25 @@ public function test_send_message($message, string $spanName, int $kind, array $
}
}

public function test_can_sustain_throw()
{
$bus = new class() implements MessageBusInterface {
public function dispatch(object $message, array $stamps = []): Envelope
{
throw new \Exception('booo!');
}
};

try {
$bus->dispatch(new SendEmailMessage('Hello Again'));
} catch (\Throwable $e) {
$this->assertCount(1, $this->storage);

/** @var ImmutableSpan $span */
$span = $this->storage[0];
}
}

public function sendDataProvider(): array
{
return [
Expand Down

0 comments on commit 5ef0ba0

Please sign in to comment.