Principle:DistrictDataLabs Yellowbrick Error Handling
| Knowledge Sources | |
|---|---|
| Domains | Error_Handling, Utilities |
| Last Updated | 2026-02-08 05:00 GMT |
Overview
Principle of providing a structured exception hierarchy that enables fine-grained error handling while maintaining compatibility with standard Python exception types.
Description
A library-specific exception hierarchy allows users to catch errors at different granularity levels. By subclassing both a library root exception and standard Python exceptions (TypeError, ValueError, etc.), exceptions can be caught by either the specific library type or the general Python type. This dual-inheritance pattern provides maximum flexibility in error handling code.
Usage
Use this principle when writing error handling for Yellowbrick operations. Catch specific exceptions (e.g., NotFitted) for targeted handling, or catch YellowbrickError for broad library error handling.
Theoretical Basis
Dual-Inheritance Exception Pattern:
Pseudo-code Logic:
# Pattern: Library exception inherits both library root and Python builtin
class LibraryTypeError(LibraryError, TypeError):
pass
# Can catch as either:
try: ...
except LibraryTypeError: ... # Specific
except TypeError: ... # General
except LibraryError: ... # Library-wide