userr

userr

Error-reporting module

This implements a union-based result type similar to https://github.com/rustedpy/result/, except that we do not wrap the “good” result.

The type Res contains either a value of a user-defined type _Value_co, an error or a list of errors.

Errors have an associated context, see the description for Err1.

Types

Res

Result type (parameterized Res [ _Value_co ] )

Note:

Wrapping an error in Res as in Res [ Err ] is meaningless, and will not do what you expect.

There are other “monadic” result types for Python that have better composability.

Res = Union [ _Value_co, Err ]

_Value_co

OK Value in our custom result type

_Parameters

Parameter specification for a decorated function

_ReturnType

Return type for a decorated function

_U

Generic type

_V

Generic type

_W

Generic type

Functions

collect

Collects single results of various types into a tuple result

collect_seq

Collects a sequence of results

flat_map

Enables the chaining computations that can error

in_context

Adds context to an error contained in a result type (when applicable)

map

Enables a computation on the value of a result

wrap

Decorates the given function, and wraps thrown exceptions into an error result

Classes

Err

Describes either an error or a list of errors

Err1

Describes a single error

ManyErr

Error class that regroups several errors