Skip to content

Commit

Permalink
Merge pull request #3594 from akutz/bugfix/fault-in-panic
Browse files Browse the repository at this point in the history
bug: Do not panic on fault.In for valid errs
  • Loading branch information
akutz authored Oct 15, 2024
2 parents eeedeaf + 0083eae commit cd4331e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fault/fault.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ func In(err any, onFaultFn OnFaultFn) {
}
In(uErr, onFaultFn)
}
case error:
// No-op
default:
panic("fault: err must implement error, types.BaseMethodFault, or " +
"types.HasLocalizedMethodFault")
Expand Down
6 changes: 6 additions & 0 deletions fault/fault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,12 @@ func TestIn(t *testing.T) {
expectedNumCalls: 0,
expectedPanic: unsupported,
},
{
name: "err is unsupported but still an err",
err: errors.New("error"),
callback: &testHarness{},
expectedNumCalls: 0,
},
{
name: "error is task.Error",
err: task.Error{},
Expand Down

0 comments on commit cd4331e

Please sign in to comment.