When we invoke Err.unwrap we can accidentally lose information about underlying error. If Err internal value is of type Exception / BaseException (somewhere in inheritance hiearachy) then when we raise ErrUnwrapError we should also include underlying exception.
How it works now?
def div(a, b) -> Result[float, Exception]:
try:
return Ok(a / b)
except Exception as exc:
return Err(exc)
div(1, 0).unwrap() # raises ErrUnwrapError, but looses ZeroDivisionError
How it should work?
def div(a, b) -> Result[float, Exception]:
try:
return Ok(a / b)
except Exception as exc:
return Err(exc)
div(1, 0).unwrap() # raises ErrUnwrapError, but also includes information about ZeroDivisionError in traceback
When we invoke
Err.unwrapwe can accidentally lose information about underlying error. IfErrinternal value is of typeException/BaseException(somewhere in inheritance hiearachy) then when we raiseErrUnwrapErrorwe should also include underlying exception.How it works now?
How it should work?