rust-ok 0.2.2__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rust_ok/err.py
CHANGED
|
@@ -47,7 +47,10 @@ class Err(Result[T_co, E_co]):
|
|
|
47
47
|
return False
|
|
48
48
|
|
|
49
49
|
def unwrap(self) -> T_co:
|
|
50
|
-
|
|
50
|
+
err = UnwrapError(f"Called unwrap on Err: {self._error_value}")
|
|
51
|
+
if isinstance(self._error_value, BaseException):
|
|
52
|
+
raise err from self._error_value
|
|
53
|
+
raise err
|
|
51
54
|
|
|
52
55
|
def unwrap_err(self) -> E_co:
|
|
53
56
|
return self._error_value
|
|
@@ -59,7 +62,10 @@ class Err(Result[T_co, E_co]):
|
|
|
59
62
|
return func(self._error_value)
|
|
60
63
|
|
|
61
64
|
def expect(self, msg: str) -> T_co:
|
|
62
|
-
|
|
65
|
+
err = UnwrapError(f"{msg}: {self._error_value}")
|
|
66
|
+
if isinstance(self._error_value, BaseException):
|
|
67
|
+
raise err from self._error_value
|
|
68
|
+
raise err
|
|
63
69
|
|
|
64
70
|
def is_ok(self) -> bool:
|
|
65
71
|
return False
|
|
@@ -87,6 +93,13 @@ class Err(Result[T_co, E_co]):
|
|
|
87
93
|
def err(self) -> E_co:
|
|
88
94
|
return self._error_value
|
|
89
95
|
|
|
96
|
+
def format_error(self) -> str:
|
|
97
|
+
from .trace import format_exception_chain
|
|
98
|
+
|
|
99
|
+
if isinstance(self._error_value, BaseException):
|
|
100
|
+
return format_exception_chain(self._error_value)
|
|
101
|
+
return str(self._error_value)
|
|
102
|
+
|
|
90
103
|
def unwrap_or_raise(
|
|
91
104
|
self,
|
|
92
105
|
exc_type: type[BaseException] = Exception,
|
rust_ok/ok.py
CHANGED
rust_ok/result.py
CHANGED
|
@@ -79,6 +79,10 @@ class Result(Generic[T_co, E_co]):
|
|
|
79
79
|
"""Return the error value if Err, otherwise None."""
|
|
80
80
|
return self.err()
|
|
81
81
|
|
|
82
|
+
def format_error(self) -> str:
|
|
83
|
+
"""Return a formatted string of the error, including traceback if available."""
|
|
84
|
+
raise NotImplementedError # pragma: no cover
|
|
85
|
+
|
|
82
86
|
def unwrap_or_raise(
|
|
83
87
|
self,
|
|
84
88
|
exc_type: type[BaseException] = Exception,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
rust_ok/__init__.py,sha256=bPwWnvWo4gP5YZxYgcTFd5VlYNM1p37-r_32Ge6K6ic,523
|
|
2
|
+
rust_ok/err.py,sha256=eZGDzXsuSfX9YsbI53Q0dyiy-C9knYfQ7Dzz0iIlUn4,3355
|
|
3
|
+
rust_ok/exceptions.py,sha256=G2FC6K6bBYrbpqUlf7paNp2M0aNWKPC_Onh5toVoOcs,325
|
|
4
|
+
rust_ok/guards.py,sha256=83zQfZPBERs1oO3qrHXrrw74rwKNnp9VQOLTlbjeZbM,496
|
|
5
|
+
rust_ok/ok.py,sha256=ypPUZb6lCbdmhLUSgJf2CffJ0bwCCWnQYM2oISnsyg4,2742
|
|
6
|
+
rust_ok/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
rust_ok/result.py,sha256=62zE8M12UEu5QBHpsd6oO_ZElAP5ZLd05_1K7yP3s1g,3361
|
|
8
|
+
rust_ok/trace.py,sha256=yUSTkGC5U6rpFGoe6Yzrs4kN7DEkh5soCFO6JxNZAPw,1218
|
|
9
|
+
rust_ok-0.3.0.dist-info/WHEEL,sha256=5DEXXimM34_d4Gx1AuF9ysMr1_maoEtGKjaILM3s4w4,80
|
|
10
|
+
rust_ok-0.3.0.dist-info/METADATA,sha256=8vSiFJKlGd8mE_Tjk6aw84Ra-nKPkfGWN02ldOoGiJA,3300
|
|
11
|
+
rust_ok-0.3.0.dist-info/RECORD,,
|
rust_ok-0.2.2.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
rust_ok/__init__.py,sha256=bPwWnvWo4gP5YZxYgcTFd5VlYNM1p37-r_32Ge6K6ic,523
|
|
2
|
-
rust_ok/err.py,sha256=LUBoF_OVzzm3Vp9CzyK1ztyrGsVrqp-ZzmFxN_WjXrs,2872
|
|
3
|
-
rust_ok/exceptions.py,sha256=G2FC6K6bBYrbpqUlf7paNp2M0aNWKPC_Onh5toVoOcs,325
|
|
4
|
-
rust_ok/guards.py,sha256=83zQfZPBERs1oO3qrHXrrw74rwKNnp9VQOLTlbjeZbM,496
|
|
5
|
-
rust_ok/ok.py,sha256=MGWZUkzBplrl2lYJ3d5Y8d_XCDI23Si-ZzG7nHe5dbI,2688
|
|
6
|
-
rust_ok/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
rust_ok/result.py,sha256=3F4DIuQzZiM8UB80GkvGXFThgUs0ESe21CCgbRnLDJ8,3183
|
|
8
|
-
rust_ok/trace.py,sha256=yUSTkGC5U6rpFGoe6Yzrs4kN7DEkh5soCFO6JxNZAPw,1218
|
|
9
|
-
rust_ok-0.2.2.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
|
|
10
|
-
rust_ok-0.2.2.dist-info/METADATA,sha256=DZTCMiVfhcn4C8Nwujc0CmyCz11Opvrc3Q3slM5U6ts,3300
|
|
11
|
-
rust_ok-0.2.2.dist-info/RECORD,,
|