MCPcopy Index your code
hub / github.com/dry-python/returns / UnwrapFailedError

Class UnwrapFailedError

returns/primitives/exceptions.py:9–32  ·  view source on GitHub ↗

Raised when a container can not be unwrapped into a meaningful value.

Source from the content-addressed store, hash-verified

7
8
9class UnwrapFailedError(Exception):
10 """Raised when a container can not be unwrapped into a meaningful value."""
11
12 __slots__ = ('halted_container',)
13
14 def __init__(self, container: Unwrappable) -> None:
15 """
16 Saves halted container in the inner state.
17
18 So, this container can later be unpacked from this exception
19 and used as a regular value.
20 """
21 super().__init__()
22 self.halted_container = container
23
24 def __reduce__(self): # noqa: WPS603
25 """Custom reduce method for pickle protocol.
26
27 This helps properly reconstruct the exception during unpickling.
28 """
29 return (
30 self.__class__, # callable
31 (self.halted_container,), # args to callable
32 )
33
34
35class ImmutableStateError(AttributeError):

Callers 4

unwrapMethod · 0.90
failureMethod · 0.90
unwrapMethod · 0.90
failureMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected