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

Error handling interfere with other Error handling middleware #35

Open
philipjoh opened this issue Jun 10, 2024 · 0 comments
Open

Error handling interfere with other Error handling middleware #35

philipjoh opened this issue Jun 10, 2024 · 0 comments

Comments

@philipjoh
Copy link

Hello!

In my project we have our own global error handler that produce a custom http response, but we noticed that the output in the http response was printed 2 times because of this call:

c.Error(err)

Reading the doc of the Error function says:

A side-effect of calling global error handler is that now Response has been committed (sent to the client) and middlewares up in chain can not change Response status code or Response body anymore.

Avoid using this method in handlers as no middleware will be able to effectively handle errors after that.

So would it make sense to just remove this call from this middleware? And perhaps instead just return the err in the end of this function? As the purpose of this library isn't to handle the error, just to log it?

@philipjoh philipjoh changed the title Error handling interferce with our own custom error handler Error handling interferce with other Error handling middleware Jun 10, 2024
@philipjoh philipjoh changed the title Error handling interferce with other Error handling middleware Error handling interfere with other Error handling middleware Jun 10, 2024
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

No branches or pull requests

1 participant