Skip to content

fix: add exception to logger context in SqsConsumer - #99

Merged
mnapoli merged 1 commit into
brefphp:masterfrom
thomask:fix-sqs-consumer-exception-context
Aug 27, 2025
Merged

mnapoli merged 1 commit into
brefphp:masterfrom
thomask:fix-sqs-consumer-exception-context

Conversation

@thomask

@thomask thomask commented Aug 26, 2025 •

Copy link
Copy Markdown
Contributor

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>
@mnapoli

mnapoli commented Aug 27, 2025

Copy link
Copy Markdown
Member

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