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

Allow handling errors with error handlers #622

Open
matthewmcgarvey opened this issue Nov 30, 2021 · 0 comments · May be fixed by #688
Open

Allow handling errors with error handlers #622

matthewmcgarvey opened this issue Nov 30, 2021 · 0 comments · May be fixed by #688

Comments

@matthewmcgarvey
Copy link
Contributor

matthewmcgarvey commented Nov 30, 2021

Description

In the docs for Kemal, one of the example error handlers is

error 403 do
  "Access Forbidden!"
end

The only way for this error handler to work is for somewhere in the code to set the status code on the response and then raise a Kemal::Exceptions::CustomException (or ancestor of it).

I believe this kind of error would be better handled like

error AccessForbiddenError do
  "Access Forbidden"
end

We could go into these error handlers with the default status of 500 unless the error is a custom Kemal error where the status could be specified on it.

What do you think?

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 a pull request may close this issue.

1 participant