gufo.err.failfast.typematch¶
TypeMatchFailFast.
TypeMatchFailFast
¶
Bases: BaseFailFast
Fail-fast on the given exception types and optional substrings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc |
Optional[Union[str, Type[BaseException]]]
|
|
None
|
match |
Optional[str]
|
Optional substring matcher. Match all when set to None. |
None
|
msg |
Optional[str]
|
Optional message to show to log before failfast.
|
None
|
Examples:
Single type:
Single type with match:
Single type with message:
Chaining:
err.setup(
fail_fast=[
TypeMatchFailFast()
.add_match(DivisionByZero)
.add_match(ValueError, match="null value")
.add_match(RuntimeError, msg="Runtime failure: %s")
]
)
__exc_to_str(t)
staticmethod
¶
Convert exception instance to string class name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t |
Type[BaseException]
|
Exception type |
required |
Returns:
Type | Description |
---|---|
str
|
Class name in form |
add_match(exc, *, match=None, msg=None)
¶
Add new exception type for the fail-fast.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc |
Union[str, Type[BaseException]]
|
Exception type or string in form "module.name". |
required |
match |
Optional[str]
|
Optional substring matcher. Match all when set to None. |
None
|
msg |
Optional[str]
|
Optional message to show to log before failfast.
|
None
|
Returns:
Type | Description |
---|---|
TypeMatchFailFast
|
Self reference to allow chaining. |
must_die(t, v, tb)
¶
Check if the proceess must die quickly.
Check if exception class matches given substrings.