Skip to content

Commit

Permalink
Merge pull request #1042 from Scalingo/fix/STORY-1378/nsq-error-no-retry
Browse files Browse the repository at this point in the history
[STORY-1378] Allow getting internal data of nsqconsumer.Error for better testability
  • Loading branch information
leo-scalingo authored Jan 20, 2025
2 parents fa2b860 + aea4157 commit 0fb96eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions nsqconsumer/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## To be Released

* feat: nsqconsumer.Error - `Unwrap` method to be compatible with `errors.Is/As()`
* feat: nsqconsumer.Error - `NoRetry` to get if the message should be retried or not to be consumed.

## v1.3.1

* fix: Use API for github.com/go-utils/logger instead of setting logger manually in context
Expand Down
10 changes: 10 additions & 0 deletions nsqconsumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ func (nsqerr Error) Error() string {
return nsqerr.error.Error()
}

// Unwrap returns the cause of the error to be compatible with errors.As/Is()
func (nsqerr Error) Unwrap() error {
return nsqerr.error
}

// NoRetry returns true if the message should not be retried to be handled
func (nsqerr Error) NoRetry() bool {
return nsqerr.noRetry
}

type ErrorOpts struct {
NoRetry bool
}
Expand Down

0 comments on commit 0fb96eb

Please sign in to comment.