D
D
Dos2020-03-03 15:25:16
API
Dos, 2020-03-03 15:25:16

API what errors to return?

Hello! Please tell me what error codes to return from the domain layer (Domain Exeption) and validation errors. It seems to me that for domain errors 400 or 409, and for validation 422. Or is it better both there and there 422?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2020-03-03
@pro-dev

Negotiate. For the most part, there is no need to detail the errors in great detail, especially at the start of the project. In general, these are all completely different errors, for example:

  • 400 - syntax error (for example, we are waiting for json, but send anything other than it)
  • 422 - semantics error (everything is fine with the request, but the object does not pass the variation, for example)
  • 409 - Status change error

D
dmitriy, 2020-03-03
@dmitriylanets

somehow everything is superficial
400 - validation error
401 - unauthorized
404 - no record
200 - successfully received
201 - created successfully
204 - updated successfully, deleted
something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question