Skip to content

Commit

Permalink
use eris.Errorf
Browse files Browse the repository at this point in the history
  • Loading branch information
CAJan93 committed Feb 5, 2024
1 parent 93b1ed9 commit 32d10df
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions eris_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,10 @@ func TestWrapType(t *testing.T) {

func TestRootWrapping(t *testing.T) {
col := "password"
rootErr := fmt.Errorf("ERROR: column \"%s\" does not exist (SQLSTATE 42703)", col)
rootErr := eris.Errorf("ERROR: column \"%s\" does not exist (SQLSTATE 42703)", col)
email := "[email protected]"
wrappedErr := eris.Wrapf(rootErr, "failed to get user by email %s", email)
wrapMsg := fmt.Sprintf("failed to get user by email %s", email)
wrappedErr := eris.Wrapf(rootErr, wrapMsg)

// validate nested error string
expect := "code(internal) failed to get user by email [email protected]: ERROR: column \"password\" does not exist (SQLSTATE 42703)"
Expand All @@ -902,12 +903,11 @@ func TestRootWrapping(t *testing.T) {
t.Errorf("Expected %s, got %s", expectRoot, unwrapGot)
}

// test unpack external
// error chain
unpacked := eris.Unpack(wrappedErr)
gotUnpackExtMsg := unpacked.ErrExternal.Error()
expectedUnpackExtMsg := wrappedErr.Error()
if gotUnpackExtMsg != expectedUnpackExtMsg {
t.Errorf("Expected %s, got %s", expectedUnpackExtMsg, gotUnpackExtMsg)
firstErr := unpacked.ErrChain[0].Msg
if firstErr != wrapMsg {
t.Errorf("Expected %s, got %s", wrapMsg, firstErr)
}

// test unpack root
Expand Down

0 comments on commit 32d10df

Please sign in to comment.