mirror of
https://github.com/logos-storage/questionable.git
synced 2026-01-06 15:53:07 +00:00
17 lines
448 B
Nim
17 lines
448 B
Nim
import std/macros
|
|
import ./without
|
|
import ./private/binderror
|
|
|
|
macro without*(condition, errorname, body): untyped =
|
|
## Used to place guards that ensure that a Result contains a value.
|
|
## Exposes error when Result does not contain a value.
|
|
|
|
let errorIdent = ident $errorname
|
|
|
|
quote do:
|
|
var error: ref CatchableError
|
|
|
|
without captureBindError(error, `condition`):
|
|
template `errorIdent`: ref CatchableError = error
|
|
`body`
|