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

Custom HTTP status codes #4

Open
davidvasquezr opened this issue Nov 20, 2019 · 1 comment
Open

Custom HTTP status codes #4

davidvasquezr opened this issue Nov 20, 2019 · 1 comment

Comments

@davidvasquezr
Copy link

Hi @brunocleite Thank you for your explanation, it is really useful.

How to use this with custom HTTP status codes?. I need an error code that is not in the HttpStatus class, something like "UserDisabled" or "EmailAlreadyExists" etc.

@eheinen
Copy link

eheinen commented Nov 22, 2019

Hi @davidvasquezr, I was just checking this project right now and saw your question.
I was thinking about your question and are you sure you want a new HTTP status code? for me those "error codes" you provided are more detailed reason than status code. Personally, I would map it as status code 409 as conflict and set a message telling the reason.
Or if you really want to categorize it, you could create a new attribute in ApiError called category or code and then you could just set there. And in the response it would be something like

409 Conflict

{
   "code": "user-disabled",
   "message": "The use is already disabled..."
}

WDYT?

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

2 participants