cape.errors: Customized exceptions for CAPE¶
This module provides CAPE-specific exceptions and methods to perform
standardized checks throughout cape. One purpose of creating
customized exceptions is to differentiate CAPE bugs and exceptions
raised by CAPE intentionally due to problems with user input or errors
detected in the execution of the integrated CFD solvers.
- exception cape.errors.CapeAttributeError¶
Bases:
AttributeError,CapeErrorCAPE exception class for missing attribute
- exception cape.errors.CapeError¶
Bases:
ExceptionBase exception class for exceptions intentionally raised by CAPE
- exception cape.errors.CapeFileError¶
Bases:
CapeErrorCAPE exception class for file based intentonal exceptions
- exception cape.errors.CapeFileNotFoundError¶
Bases:
FileNotFoundError,CapeErrorCAPE exception for missing required file
- exception cape.errors.CapeIndexError¶
Bases:
IndexError,CapeErrorCAPE exception for objects with the wrong size
- exception cape.errors.CapeNotImplementedError¶
Bases:
NotImplementedError,CapeErrorCAPE exception for capability not yet implemented
- exception cape.errors.CapeNotSupportedError¶
Bases:
RuntimeError,CapeErrorCAPE exception for feature not supported on current system
- exception cape.errors.CapeRuntimeError¶
Bases:
RuntimeError,CapeErrorCAPE exception that does not fit other categories
- exception cape.errors.CapeTypeError¶
-
CAPE exception for objects with the wrong type
- exception cape.errors.CapeValueError¶
-
CAPE exception for objects with bad values
- cape.errors.assert_isinstance(obj: Any, cls_or_tuple: type | tuple, desc: str | None = None)¶
Conveniently check types
Applies
isinstance(obj, cls_or_tuple)but also constructs a :class;`TypeError` and appropriate message if test fails- Call:
>>> assert_isinstance(obj, cls, desc=None) >>> assert_isinstance(obj, cls_tuple, desc=None)
- Inputs:
- Raises:
CapeTypeErrorif type of obj does not match cls or cls_tuple
- Version:
2024-06-19
@ddalle: v1.0
- cape.errors.assert_len(obj: list | tuple, length: int, desc: str | None = None)¶
Conveniently check length
- Call:
>>> assert_len(obj, length, desc=None)
- Inputs:
- Raises:
CapeIndexErrorif type of obj does not match cls or cls_tuple
- Version:
2024-06-19
@ddalle: v1.0
- cape.errors.assert_which(cmdname: str)¶
Ensure that a specific executable exists
- Call:
>>> assert_which(cmdname)
- Inputs:
- cmdname:
str Name of executable
- cmdname:
- Raises:
CapeFileNotFoundErrorif cmdname not on PATH
- Versions:
2025-06-19
@ddalle: v1.0