OxL Reference

error fail-type

error Standard: [§6.5]

What it means#

fail e returns the error e from the function, so the type of e MUST be part of the declared return type; the same holds for errors propagated with e? (§6.5). The return type must be a union that mentions the error type explicitly.

Example#

oxl✓ checked in CI
@error data NotFound { what: str }

fn find(id: u64) -> str | NotFound {
  fail Timeout      // <- fail-type
}
error
fail-type

How to fix#

oxl✓ checked in CI
@error data NotFound { what: str }

fn find(id: u64) -> str | NotFound {
  fail NotFound{ what: "user" }
}

Fail with an error from the declared set, or extend the return type (-> str | NotFound | Timeout).

See also#

See also

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides