Responses and Failures

Let’s learn about responses that succeed and fail in clean architecture.

There’s a wide range of errors that can occur when the use case code is executed. We discussed validation errors in the previous lesson, “Request Validation”. There are many other errors that can also occur, such as business logic errors and errors from the repository layer or other external systems that the use case interfaces with. Regardless of what error occurs, the use case should always return an object with a known structure (the response). So, we need a new object that provides good support for different types of failures.

Get hands-on with 1200+ tech skills courses.