Skip to content

Conversation

@bradleyjkemp
Copy link
Contributor

Currently by calling .Error() on job worker errors before logging them, data is being thrown away that cannot be used by slog handlers.

I use a structured error library where errors can contain metadata like status codes or user IDs. In my slog handler I can extract these values and e.g. send this on to an error tracking service

But, this metadata isn't present in the basic .Error() output and so it's being thrown away by this line which converts the error to a string.

Instead I think you can use the slog.Any attribute type instead, by default this will have the same behaviour as the current code (printing out the error text), but allows custom slog handlers to extract the original error type

@brandur
Copy link
Contributor

brandur commented Oct 1, 2025

Seems reasonable, thanks!

@bradleyjkemp Could you add a changelog entry under a "changed" section following the conventions in the file? (Full sentences, link up the PR.)

@bgentry Seem okay to you?

Copy link
Contributor

@bgentry bgentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@bgentry bgentry enabled auto-merge (squash) October 7, 2025 22:13
@bgentry bgentry merged commit 142819f into riverqueue:master Oct 7, 2025
11 checks passed
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.

3 participants