Err¶
err
¶
Err variant of the Result type — represents a failed computation.
Wrap an error with Err(error) to short-circuit chains of map and
flat_map calls. This is the left side of the Either monad (the
Left in Haskell / Scala), carrying the reason the computation could not
proceed.
Err
¶
Bases: Result[ValueType, ErrorType]
Represents a failed result, holding an error of type ErrorType.
Source code in src/forging_blocks/foundation/result/err.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
is_ok: bool
property
¶
Always False — this variant does not hold a success value.
is_err: bool
property
¶
Always True — this variant holds an error.
value: ValueType
property
¶
Raises ResultAccessError — there is no success value to access.
error: ErrorType
property
¶
The wrapped error.
__init__(error: ErrorType) -> None
¶
__repr__() -> str
¶
__str__() -> str
¶
__eq__(other: object) -> bool
¶
Two Errs are equal when their wrapped errors are equal.
Source code in src/forging_blocks/foundation/result/err.py
__hash__() -> int
¶
map(fn: Callable[[ValueType], MappedValueType]) -> Result[MappedValueType, ErrorType]
¶
Pass through unchanged — there is no value to transform.
This is the Functor map on the error path — the error propagates
unchanged while fn is silently ignored.
Source code in src/forging_blocks/foundation/result/err.py
map_error(fn: Callable[[ErrorType], MappedErrorType]) -> Result[ValueType, MappedErrorType]
¶
Apply fn to the wrapped error and wrap the result in a new Err.
Source code in src/forging_blocks/foundation/result/err.py
flat_map(fn: Callable[[ValueType], Result[MappedValueType, ErrorType]]) -> Result[MappedValueType, ErrorType]
¶
Pass through unchanged — short-circuit the chain.
get_value_or(default: ValueType) -> ValueType
¶
Return default — there is no success value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default
|
ValueType
|
The value to return when this result is an error. |
required |
Returns:
| Type | Description |
|---|---|
ValueType
|
|
Source code in src/forging_blocks/foundation/result/err.py
get_value_or_else(fn: Callable[[ErrorType], ValueType]) -> ValueType
¶
Call fn with the wrapped error to compute a fallback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fn
|
Callable[[ErrorType], ValueType]
|
A callable that accepts the error and returns a recovery value |
required |
Returns:
| Type | Description |
|---|---|
ValueType
|
The result of |