Skip to content

Std.Cause

opaque type Cause[E]

The cause of a failure. E is the error set it can fail with.

enum CauseKind

The two kinds of causes.

  • Fail

    An error raised with fail. Shows up in E.

  • Die

    A defect ([error.defect]). Does not show up in the type.

fn kind[E](c: Cause[E]) -> CauseKind

The kind of the cause.

fn to_string[E](c: Cause[E]) -> String

The cause as text: error: ... or defect: ....

fn raise[A, E](c: Cause[E]) -> A fails E

Raises the cause again: Fail fails with the error, and Die is a defect.