What's the best way to select an appropriate HTTP status code when an order can't be processed due to the customer's shipping address being outside the delivery zone? I've written a blog post discussing common solutions for handling business error responses when there isn't a clear status code that matches the situation. I also touch on some industry standards and how major companies like Stripe tackle this problem. I'd love to hear thoughts from others on this!
3 Answers
I think mixing the transmission layer with business logic can lead to confusion. It might complicate things unnecessarily. What do you think is a better approach?
Using HTTP errors for this kind of situation can really complicate things. It’s often better to handle these issues at the application level instead of relying solely on HTTP status codes.
Yeah, but isn’t using a 422 status code with structured error messages becoming a standard practice? It makes explaining the error clearer!
That's a fair point, but how to handle business rule violations is really up for debate.
I liked your article! The mix of HTTP errors with descriptive strings is clever. We've faced similar challenges with our model APIs; we decided to stick with a 200 status code and send back strings, but your approach seems promising.
I'd love to hear your thoughts on this. How would you separate those concerns?