ErrnoException.enforceRetPtr

Calls enforceRet expecting Func to return non-NULL

Wraps enforceRet with a lambda that verifies that return value is not null

class ErrnoException
Caller!(typeof(&Func))
enforceRetPtr
(
alias Func
)
(
istring file = __FILE__
,
int line = __LINE__
)

Return Value

Type: Caller!(typeof(&Func))

same as enforceRet

Examples

extern(C) static void* func ( )
{
    .errno = EMFILE;
    return null;
}

try
{
    (new ErrnoException).enforceRetPtr!(func).call();
    test(false);
}
catch (ErrnoException e)
{
    test!("==")(e.message(), "func: Too many open files"[]);
    test!("==")(e.line, __LINE__ - 6);
}

Meta