SplitScript reference / Language / throw

throw

keyword

throw error

Transfers an error to the nearest failure boundary.

throw is an ordinary Never-typed expression. Inside retry, it ends the current attempt and retries the complete operand on the next attached update. Otherwise it returns an error from the enclosing T! function or rejects the current state-field value. The error expression must be a String. Because it never yields locally, it can be used directly as a fallback else operand or in any other expression position.

Examples

Return an error

fn requireAddress(value) -> address! {
    if value == 0 { throw "address is null" }
    return value
}