CodePark/ questions / Error handling & API boundaries
START PRACTICINGPRACTICE
Backend question · Software design & patterns › Error handling & API boundaries

Which of these is a domain error rather than an infrastructure error?

The customer tried to cancel an order that has already shipped

"The customer tried to cancel an order that has already shipped" is a domain error. A domain error is a broken business rule. The user can understand it and can often fix it. It maps to a 4xx response.

The other three options are infrastructure errors: a dependency (the database, Redis, the payment provider) failed for technical reasons. These are usually safe to retry, and they map to 5xx or 503. The client did nothing wrong.