Skip to content

Commit

Permalink
Stop initialising the IsUnexpected flag to false for new errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mattcottam-monzo committed Aug 30, 2024
1 parent 073654f commit 45a87db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func TestSetIsRetryable(t *testing.T) {

func TestSetIsUnexpected(t *testing.T) {
err := New("code", "message", nil)
assert.False(t, *err.IsUnexpected)
assert.Nil(t, err.IsUnexpected)

err.SetIsUnexpected(true)
assert.True(t, *err.IsUnexpected)
Expand Down
7 changes: 3 additions & 4 deletions factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ func RateLimited(code, message string, params map[string]string) *Error {
// Builds a stack based on the current call stack
func errorFactory(code string, message string, params map[string]string) *Error {
err := &Error{
Code: ErrUnknown,
Message: message,
Params: map[string]string{},
IsUnexpected: &notUnexpected,
Code: ErrUnknown,
Message: message,
Params: map[string]string{},
}
if len(code) > 0 {
err.Code = code
Expand Down

0 comments on commit 45a87db

Please sign in to comment.