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

Returning errors instead of throwing? #9

Open
lonix1 opened this issue Oct 7, 2021 · 2 comments
Open

Returning errors instead of throwing? #9

lonix1 opened this issue Oct 7, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@lonix1
Copy link

lonix1 commented Oct 7, 2021

Using exceptions for flow control is very "heavy".

Anyone figure out how to return a result with errors, instead of throwing exceptions?

@GetoXs
Copy link
Owner

GetoXs commented Oct 10, 2021

You are right. But do you know any other way to pass validation failure to exception handler on middleware level?

@lonix1
Copy link
Author

lonix1 commented Oct 10, 2021

Yes it can be done using a little bit of reflection. It feels "dirty", but it's still faster than using exceptions. (Doing it that way there is no need for exception handlers, the conversion from validation failure to HTTP response can be done in the controller.)

However I still hope there is another way, without exceptions and reflection.

(Feel free to close. Take a look at that link it's excellent.)

@GetoXs GetoXs added the enhancement New feature or request label Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants