Sobes.tech
Middle

Do you use standard HTTP statuses or do you have custom ones? How do you feel about a situation where the response has a status 200, but contains an error inside?

sobes.tech AI

Answer from AI

Standard HTTP statuses should be used as intended, as they help clients and developers quickly understand the result of a request. For example, 200 — successful request, 404 — resource not found, 500 — internal server error.

Using custom HTTP statuses is not recommended, as it violates standards and can lead to incorrect handling of responses.

If a response has a status of 200, but contains an error internally, it can confuse the client and complicate error handling. It is better to use the appropriate status (e.g., 4xx or 5xx) for errors and return details in the response body. If for some reason you need to return 200, there must be a clear error information field in the body, and the client should be able to handle this correctly.