Skip to content

Commit

Permalink
fix: make panic handling in ers package more consistent, add assertio…
Browse files Browse the repository at this point in the history
…n to test

(cherry picked from commit 5d75827)
  • Loading branch information
tychoish committed Jan 21, 2025
1 parent e7fbcfc commit 2f105d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ers/panic.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ func ParsePanic(r any) error {
case string:
return Join(New(err), ErrRecoveredPanic)
case []error:
return Join(err...)
st := Stack{}
st.Add(err...)
st.Add(ErrRecoveredPanic)
return st.Resolve()
default:
return Join(fmt.Errorf("[%T]: %v", err, err), ErrRecoveredPanic)
}
Expand Down
1 change: 1 addition & 0 deletions ers/panic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestPanics(t *testing.T) {
}
assert.NotPanic(t, func() {
defer Recover(ob)
assert.True(t, !called)
panic("hi")
})
assert.True(t, called)
Expand Down

0 comments on commit 2f105d9

Please sign in to comment.