You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there is a panic within a With callback, the service will currently crash. This means using RequireValue, which panics if the Get handler returns an error, will be very dangerous within a With callback.
Example
s.With("library.book.1337", func(r res.Resource) {
// Since RequireValue will panic if the Get handler// returns a NotFound error, the entire service will crash.book:=r.RequireValue.(*Book)
})
Solution
Any panic that happens within the With callback should be recovered and logged as an error.
Since it the callback is (most likely) running on a different goroutine than the caller of With, it will not be possible to return any recovered panic as an error on the With call.
The text was updated successfully, but these errors were encountered:
Issue
When there is a panic within a
With
callback, the service will currently crash. This means usingRequireValue
, which panics if the Get handler returns an error, will be very dangerous within aWith
callback.Example
Solution
Any panic that happens within the
With
callback should be recovered and logged as an error.Since it the callback is (most likely) running on a different goroutine than the caller of
With
, it will not be possible to return any recovered panic as an error on theWith
call.The text was updated successfully, but these errors were encountered: