![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|
Functions | |
| str | format_exception (BaseException exc, Union[type, None] type) |
| List[str] | transform_error (Union[ClassValidationError, IterableValidationError, BaseException] exc, str path="$", Callable[[BaseException, Union[type, None]], str] format_exception=format_exception) |
Cattrs validation.
| str cattrs.v.format_exception | ( | BaseException | exc, |
| Union[type, None] | type | ||
| ) |
The default exception formatter, handling the most common exceptions. The following exceptions are handled specially: * `KeyErrors` (`required field missing`) * `ValueErrors` (`invalid value for type, expected <type>` or just `invalid value`) * `TypeErrors` (`invalid value for type, expected <type>` and a couple special cases for iterables) * `cattrs.ForbiddenExtraKeysError` * some `AttributeErrors` (special cased for structing mappings)
| List[str] cattrs.v.transform_error | ( | Union[ClassValidationError, IterableValidationError, BaseException] | exc, |
| str | path = "$", |
||
| Callable[ [BaseException, Union[type, None]], str ] | format_exception = format_exception |
||
| ) |
Transform an exception into a list of error messages.
To get detailed error messages, the exception should be produced by a converter
with `detailed_validation` set.
By default, the error messages are in the form of `{description} @ {path}`.
While traversing the exception and subexceptions, the path is formed:
* by appending `.{field_name}` for fields in classes
* by appending `[{int}]` for indices in iterables, like lists
* by appending `[{str}]` for keys in mappings, like dictionaries
:param exc: The exception to transform into error messages.
:param path: The root path to use.
:param format_exception: A callable to use to transform `Exceptions` into
string descriptions of errors.
.. versionadded:: 23.1.0