Skip to content

Commit

Permalink
append wrapped errors message
Browse files Browse the repository at this point in the history
  • Loading branch information
kenanfarukcakir committed Apr 19, 2023
1 parent 6ac2ca3 commit 32c5062
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion config/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,10 @@ type RemoteMultipartError struct { // UnWrappable
}

func (nf RemoteMultipartError) Error() string {
return fmt.Sprintf("%s", nf.msg)
if nf.wrappedErr != nil {
return fmt.Sprintf("%s, %s", nf.msg, nf.wrappedErr.Error())
}
return nf.msg
}

func (nf RemoteMultipartError) Unwrap() error {
Expand Down
5 changes: 4 additions & 1 deletion core/scenario/data/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ type RemoteCsvError struct { // UnWrappable
}

func (nf RemoteCsvError) Error() string {
return fmt.Sprintf("%s", nf.msg)
if nf.wrappedErr != nil {
return fmt.Sprintf("%s,%s", nf.msg, nf.wrappedErr.Error())
}
return nf.msg
}

func (nf RemoteCsvError) Unwrap() error {
Expand Down
6 changes: 2 additions & 4 deletions core/scenario/data/csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ func TestReadCsv_RemoteErr(t *testing.T) {
if !errors.As(err, &remoteCsvErr) {
t.Errorf("Expected: %v, Found: %v", remoteCsvErr, err)
}
if remoteCsvErr.Error() != "can not get response" {
t.Errorf("Expected: %v, Found: %v", "can not get response", remoteCsvErr.msg)
}
if remoteCsvErr.Unwrap() == nil {
t.Errorf("Expected: %v, Found: %v", "not nil", remoteCsvErr.Unwrap())
}
Expand All @@ -76,7 +73,8 @@ func TestWrapAsRemoteCsvError(t *testing.T) {
if !errors.As(csvErr, &remoteCsvErr) {
t.Errorf("Expected: %v, Found: %v", remoteCsvErr, csvErr)
}
if remoteCsvErr.Error() != msg {
errmsg := remoteCsvErr.Error()
if errmsg != msg+",error" {
t.Errorf("Expected: %v, Found: %v", msg, remoteCsvErr.msg)
}
}
Expand Down

0 comments on commit 32c5062

Please sign in to comment.