OxL Reference

fn panic

Aborts the current task with a message (§6.6).

Example:

oxl✓ checked in CI
fn pick(i: usize) -> str {
  if i > 1 { panic("no such item") }
  ["a", "b"][i]
}

fn main() io {
  let r = scope {
    spawn pick(5)
    ()
  }
  match r {
    Panicked p => print("panic: {p.msg}")
    _ => print("fine")
  }
}
Output
panic: no such item
@intrinsic("panic") pub(api) fn panic(msg: str) -> never

Since. 1.0.0-beta

Parameters

NameType
msgstr

Returns

never

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/functions.oxl:112

See also