Search⌘ K

Overview of Error Management

Explore how to handle errors effectively within the use case layer in clean architecture using Python. Understand the roles of request and response objects in managing input and output data, and learn to implement filters and structured error handling for more reliable applications.

Overview

In every software project, a large part of the code is dedicated to error management. This part of the code has to be infallible. Yet, more often than not, we find that we’ve left out cases that give errors, or we’ve provided a condition that we thought would never fail but does.

In clean architecture, the main process is the creation of use cases and their execution. As we can expect, this is also the main source of errors. So, the use cases layer is where we have to implement error management. This isn’t to say that errors can’t also come from the domain models layer. However, since those models are created by the use cases, the errors that aren’t managed by the models themselves are automatically treated as errors of the use cases.

Request and Responses

We can divide the error management code into two ...