Skip to content

Conversation

@thomask
Copy link
Contributor

@thomask thomask commented Aug 26, 2025

Summary

  • Added exception objects to the logger context when logging exception messages in SqsConsumer
  • This ensures stack traces are visible in monitoring tools like Sentry when errors occur

Motivation

Adding the exception to the context will make sure that stack traces are visible in tools like Sentry when errors occur while processing messages. Previously, when logging the exception message, the full exception object with stack trace was not included in the context, which made debugging more difficult.

Changes

  • Modified SqsConsumer::handleSqs() to pass exception objects in the logger context when logging exception messages
  • Changed $this->logger->error($exception) to $this->logger->error($exception->getMessage(), ['exception' => $exception])
  • Changed $this->logger->error($exception->getMessage()) to $this->logger->error($exception->getMessage(), ['exception' => $exception])
  • Left the initial error messages (SQS record with id "%s" failed to be processed...) unchanged

🤖 Generated with Claude Code

Adding the exception to the context will make sure that stack traces
are visible in tools like Sentry when errors occur while processing messages.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@thomask thomask force-pushed the fix-sqs-consumer-exception-context branch from 3935be9 to ec19aed Compare August 26, 2025 15:12
@mnapoli
Copy link
Member

mnapoli commented Aug 27, 2025

Thank you!

@mnapoli mnapoli merged commit a6bd31a into brefphp:master Aug 27, 2025
5 checks passed
@thomask thomask deleted the fix-sqs-consumer-exception-context branch August 27, 2025 12:09
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

Successfully merging this pull request may close these issues.

2 participants