Module result

Types

Result*[T] = object
  case isSuccess*: bool
  of true:
      value*: T

  of false:
      error*: ref Exception

  
Either a value or an error.   Source Edit
InstantationInfo* = tuple[filename: string, line: int, procname: string]
  Source Edit

Procs

proc getOriginal*(exc: ref Exception): ref Exception
  Source Edit
proc printError*(err: ref Exception)
  Source Edit
proc isError*[T](r: Result[T]): bool
  Source Edit
proc just*[T](r: T): Result[T]
  Source Edit
proc just*(): Result[void]
  Source Edit
proc fillExceptionName*[Exc: ref Exception](exc: Exc)
  Source Edit
proc error*[T, Exc: ref Exception](typename: typedesc[T]; theError: Exc): Result[T]
  Source Edit
proc error*[T](typename: typedesc[T]; theError: string): Result[T]
  Source Edit
proc get*[T](r: Result[T]): T
  Source Edit
proc `$`*[T](r: Result[T]): string
  Source Edit
proc onSuccessOrErrorR*[T](f: Result[T]; onSuccess: (proc (t: T));
                          onError: (proc (t: ref Exception)))
  Source Edit
proc onSuccessOrErrorR*(f: Result[void]; onSuccess: (proc ());
                       onError: (proc (t: ref Exception)))
  Source Edit
proc getResult*(r: Result): auto
  Source Edit
proc isCompleted*(r: Result): bool
  Source Edit

Templates

template catchError*(e: untyped): untyped
Converts errors from e into error(...) and other results into just(e)   Source Edit