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

Wrap the context render panic. #3425

Closed
wants to merge 1 commit into from

Conversation

danmux
Copy link

@danmux danmux commented Dec 6, 2022

The utility of the c.JSON helper or other context.Render methods not returning an error simplifies client code.

There are rare errors during rendering that result in a panic, which most production systems will handle in middleware.

This introduces the ability to detect that it is a gin rendering error in the panic handler as opposed to other handler logic panics.

To be able to trap c.JSON render panics this PR will also need #3390 - which changes the JSON renderer to be more consistent, until that is also merged this context Render panic will not fire.

  • With pull requests:
    • Open your pull request against master
    • Your pull request should have no more than two commits, if not you should squash them.
    • It should pass all tests in the available continuous integration systems such as GitHub Actions.
    • You should add/modify tests to cover your proposed code changes.
    • If your pull request contains a new feature, please document it on the README.

@danmux danmux force-pushed the dm/panic-error-type branch from 7fe2ee0 to 5ebc439 Compare December 6, 2022 13:51
Panic handling middleware can test for this error and decide to
supress the error or not.
@danmux danmux force-pushed the dm/panic-error-type branch from 5ebc439 to e7f7980 Compare December 6, 2022 13:52
@danmux danmux changed the title Introduce a render.Error returned from the render panic. Wrap the context render panic. Dec 6, 2022
@danmux danmux closed this Dec 6, 2022
@danmux
Copy link
Author

danmux commented Dec 6, 2022

better handled by. https://github.com/gin-gonic/gin/pull/2150/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant