Skip to main content

MoltResult

Type Alias MoltResult 

Source
pub type MoltResult = Result<Value, Exception>;
Expand description

The standard Result<T,E> type for Molt code.

This is the return value of all Molt commands, and the most common return value throughout the Molt code base. Every Molt command returns a Value (i.e., Ok(Value)) on success; if the command has no explicit return value, it returns the empty Value, a Value whose string representation is the empty string.

A Molt command returns an Exception (i.e., Err(Exception)) whenever the calling Molt script should return early: on error, when returning an explicit result via the return command, or when breaking out of a loop via the break or continue commands. The precise nature of the return is indicated by the Exception’s ResultCode.

Many of the functions in Molt’s Rust API also return MoltResult, for easy use within Molt command definitions. Others return Result<T,Exception> for some type T; these are intended to produce a T value in Molt command definitions, while easily propagating errors up the call chain.

Aliased Type§

pub enum MoltResult {
    Ok(Value),
    Err(Exception),
}

Variants§

§1.0.0

Ok(Value)

Contains the success value

§1.0.0

Err(Exception)

Contains the error value