Result

Overview

The Result object represents either a success or a failure, holding a value for only one state at a time. The typical usage of a Result is for safely returning and propagating runtime errors.

Fields

.is_okay

fn -> Boolean

Determines if a Result contains a value.

.is_error

fn -> Boolean

Determines if a Result contains an error.

.unwrap_okay

fn (message?: String) -> T

Attempts getting an encapsulated value. If no value exists, the program will panic.

.unwrap_error

fn (message?: String) -> E

Attempts getting an encapsulated error. If no error exists, the program will panic.

Statics

.wrap

fn [T: Future[Any]](future: T) -> Result[Any, Exception]

Converts a Future into a Result value.

.okay

fn [T = Any, E = Any](value: T) => Result[T, E]

Creates a Result with a value.

.error

fn [T = Any, E = Any](error: E) => Result[T, E]

Creates a Result with an error.

On this page