eris package
eris package
The Greek Goddess of Strife and Discord… A better way to handle, trace, and log errors in Python.
- class AbstractResult(*args, **kwds)[source]
Bases:
abc.ABC,Generic[eris._result.T,eris._result.E]This class defines what a Result object looks like.
- abstract err()[source]
Returns None if successful or an Exception type otherwise.
- Return type
Optional[~E]
- abstract unwrap()[source]
Returns real return type or raises an exception if unsuccessful.
- Return type
~T
- exception ErisError(emsg, up=0)[source]
Bases:
ExceptionCustom general-purpose exception.
- Parameters
emsg (
str) –up (
int) –
- chain(other)[source]
Chains this exception to another.
- Parameters
other (
Exception) –- Return type
ForwardRef
- to_json()[source]
Converts this error into a list of dictionaries.
This list is JSON serializable and is composed of data on this exception and any that are chained to it.
NOTE: The list is sorted from last-to-first exception to be raised (i.e. this exception, the exception that caused this exception, etc…).
- Return type
List[ForwardRef]
- class ErisErrorDict(*args, **kwargs)[source]
Bases:
dictAn Error type represented as a dictionary.
- caused_by
- exc_info
- file_name
- func_name
- lineno
- module_name
- stack
- class Err(error_spec, up=0)[source]
Bases:
eris._result.AbstractResult[eris._result.T,eris._result.E]Err result type.
A value that signifies failure and which stores arbitrary data for the error.
- chain(exc_or_err)[source]
Wraps another Exception object with this Exception object.
- Parameters
self (~ErrType) –
exc_or_err (
Union[Exception,Err]) –
- Return type
~ErrType
- error_spec
- unwrap()[source]
Returns real return type or raises an exception if unsuccessful.
- Return type
NoReturn
- unwrap_or(default)[source]
Returns real return type if successful or
defaultotherwise.- Parameters
default (~T) –
- Return type
~T
- unwrap_or_else(op)[source]
Returns real return type if successful or
op(e)otherwise.- Parameters
op (
Callable[[~E], ~T]) –- Return type
~T
- up = 0
- class LazyResult(func, *args, **kwargs)[source]
Bases:
eris._result.AbstractResult[eris._result.T,eris._result.E]See help(return_lazy_result).
- result()[source]
Retrieve the Result object corresponding with this LazyResult.
Calls the function corresponding with this LazyResult (this function will only be called once, even if this method is called multiple times) and returns the same Result returned by that function.
- class Ok(_value)[source]
Bases:
eris._result.AbstractResult[eris._result.T,eris._result.E]Ok result type.
A value that indicates success and which stores arbitrary data for the return value.
- Parameters
_value (~T) –
- return_lazy_result(func)[source]
Converts the return type of a function from result to a “lazy” result.
In order to fetch the real return type from lazy_result, you must call lazy_result.result() or any other valid Result method [e.g. lazy_result.unwrap()].
This decorator is useful when dealing with functions that return Result[None] (i.e. functions that are used soley for their side-effects), since it makes it harder to ignore potential errors.