Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic not recovered within With #38

Open
jirenius opened this issue Jul 11, 2019 · 0 comments
Open

Panic not recovered within With #38

jirenius opened this issue Jul 11, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@jirenius
Copy link
Owner

Issue

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.

@jirenius jirenius added the bug Something isn't working label Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant