codex-storage / questionable

Elegant optional types for Nim
Other
116 stars 5 forks source link

Retrieve optional error from Result #18

Closed markspanbroek closed 2 years ago

markspanbroek commented 2 years ago

Allows for error handling code that is only interested in the error part of a Result. For instance when dealing with ?!void Results.

proc foo: ?!void =
  # do something that might fail

if error =? foo().errorOption:
  echo "something went wrong: ", error.msg