Skip to content

Errors and Option

Vow does not have null. Absence is Option<T>; fallible work is Result<T, E>.

Hands-on: Option & Result tutorial · Syntax ergonomics.

fn unwrap_or(opt: Option<int>, fallback: int) -> int {
return opt ?? fallback
}

Or exhaustive match on Some / None:

return match caps.fs_read {
Some(c) => with c { read_poc("/tmp/vow_poc.txt") },
None => 0 - 100
}

Some / None answer “was this grant passed at launch?” — not “did the call fail?” For failures, match Result (Ok / Err). See Option and Result tutorial.

I/O builtins return Result<…, int> (integer error codes for v1).

// fragment-only
return match read_file(path) {
Ok(s) => len(s),
Err(_) => 0 - 1
}
// fragment-only
let ok_val = try fallible(true) catch (e) {
e
}
try {
let x = fallible(false)
} catch (e) {
print("caught err=", e)
}

Propagate Err to the caller in one character when the enclosing function returns Result.

Caps fields are Option<Cap> — no grant means None.

Discarding a Result without matching / try / ? is a type error.

Terminal window
vow check tests/lang/ignored_result.vow --json
Form Example
?? none_i ?? 99
?. Some("abc")?.len()
try / catch Local Result handling
? Propagate Err