result icon indicating copy to clipboard operation
result copied to clipboard

feat: add `unwrap_or_raise_itself()` if a value of `Err` is a `BaseException`

Open Colk-tech opened this issue 1 year ago • 0 comments

This PR enhances #192. If this is merged, Close: #192.

Rather than overriding the existing behavior of unwrap_or_raise(), I added a new method: unwrap_or_raise_itself().

With this addition, users can better determine if an Err value is a BaseException. This option may be helpful in such cases.

The unwrap_or_raise_itself() method is now available in both Ok and Err classes.

Example:

e = Err(RuntimeError("nay"))
e.unwrap_or_raise_itself()
>>> e.unwrap_or_raise_itself()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Users/colk/Repositories/github.com/Colk-tech/result/src/result/result.py", line 374, in unwrap_or_raise_itself
    raise self._value
RuntimeError: nay

By the way, this is my first time creating a PR for an OSS project, so I’d be grateful for any advice you might have :)

Colk-tech avatar Oct 28 '24 17:10 Colk-tech