error

Error handling library for MoonBit

error
moon add YumeXi/error@0.2.3
Download zip
Author
Version
0.2.3
License
Apache-2.0
Last updated
2 days ago
Downloads
37
README

#YumeXi/error

Structured error handling for MoonBit. Provides error cause chains and precondition checks.

#
Cause

using @YumeXi/error/cause { type Cause }

#
bail

#callsite(autofill(loc))
fn[T] bail(msg : String, loc~ : SourceLoc) -> T raise
Cause

Just raise an error with a message
#callsite(autofill(loc))
fn[T] by(err : Error, msg? : String, loc~ : SourceLoc) -> T raise
Cause

Chains or wraps an error with an optional message

#
ensure

#callsite(autofill(loc))
fn ensure(cond : Bool, error? : Error, msg~ : String, loc~ : SourceLoc) -> Unit raise
SourcedError

#
ensured

#callsite(autofill(loc))
fn[T] ensured(val : T, cond : Bool, error? : Error, msg~ : String, loc~ : SourceLoc) -> T raise
SourcedError

#
passby

#callsite(autofill(loc))
fn[T] passby(f : () -> T raise, msg? : String, loc~ : SourceLoc) -> T raise
Cause

Call the function and wrap any error it raises

Source Files

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io