Not every exception your code raises signals that a downstream system is failing. Business logic exceptions — such asDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/danielfm/pybreaker/llms.txt
Use this file to discover all available pages before exploring further.
CustomerNotFound, ValidationError, or PermissionDenied — indicate application-level issues, not infrastructure problems. If these are counted as failures, the circuit can trip even when the underlying service is perfectly healthy, causing unnecessary outages.
PyBreaker lets you declare a list of excluded exceptions. Any exception matching an exclusion is re-raised normally but is not counted against the failure threshold and will not trip the circuit breaker.
Excluding by Exception Type
Pass exception types via theexclude parameter at construction time, or register them after the fact using add_excluded_exception / add_excluded_exceptions.
issubclass internally, so subclasses of excluded exception types are also excluded. Registering ValidationError will also exclude EmailValidationError(ValidationError), PhoneValidationError(ValidationError), and so on.
Excluding with a Callable Predicate
When the exception type alone isn’t granular enough, pass a callable instead. The callable receives the exception instance and should returnTrue if the exception should be excluded (not counted as a failure).
404 Not Found) and genuine failures (e.g., 503 Service Unavailable) and you need to distinguish them by value.
Mixing Types and Callables
Types and callables can be freely combined in the sameexclude list. PyBreaker evaluates each entry in order and excludes the exception if any entry matches.
Checking and Removing Exclusions
Inspect the current exclusion list or remove a previously registered exclusion at any time. Useis_system_error() to test how the circuit breaker would classify a specific exception instance.
is_system_error() returns False for excluded exceptions (they won’t count as failures) and True for everything else (they will).
