ErrnoException.enforceRet

Calls Func automatically checking errno and storing name

If verify returns false when called with return value of Func, global errno gets checked and this ErrnoException instance gets thrown with message set from that errno and caller name set to Func identifier.

Presence of additional wrapper struct is dictated by limitations of dmd1 type inference in method/function signatures.

class ErrnoException
Caller!(typeof(&Func))
enforceRet
(
alias Func
)
(
bool function
()
verify
,
istring file = __FILE__
,
int line = __LINE__
)

Parameters

Func

function alias, usually C library function

verify bool function
(
ReturnTypeOf!(Func)
)

lambda that takes return value of Func and returns true itself if result is considered successful

file istring

file where the expr is evaluated

line int

line where the expr is evaluated

Return Value

Type: Caller!(typeof(&Func))

proxy Caller value with a single call method which accepts same arguments as Func and throws this exception if verify(Func(args)) evaluates to false.

Meta