Light Dark

Functions

cancel core

fn (msg: Str): Cancellation
fn (msg: Str, lazy data: Any): Cancellation

Halt execution with a Cancellation. The current run terminates, the engine emits a run:cancel event carrying the structured cancellation, and any code after the call site is not executed.

Context-aware: produces ::hot::run/Cancellation in a run, ::hot::task/Cancellation in a task.

Use cancel() for orderly stops (user-initiated abort, deadline exceeded, downstream dependency unavailable) where the failure mode is expected and the run should end without raising an alert.

Example

// Simple cancellation
cancel("Operation cancelled by user")

// Cancellation with structured details
cancel("Task timeout", {"elapsed": 30000})

exit core

fn (code: Int)

Exit the current execution with status code.

Behavior varies by context:

  • CLI: Exits the process with the given code
  • Worker: exit(0) completes successfully; exit(N) acts like fail()

Example

// Exit successfully
exit(0)

// Exit with error code (will fail on worker)
exit(1)

fail core

fn (lazy err: Any): Failure
fn (msg: Str, lazy err: Any): Failure

Halt execution with a Failure. The current run terminates, the engine emits a run:fail event carrying the structured failure, and any code after the call site is not executed.

Context-aware: produces ::hot::run/Failure in a run, ::hot::task/Failure in a task.

Use fail() for unrecoverable conditions (programmer error, missing configuration, exhausted budgets). For recoverable errors that the caller is expected to handle, return err(value) instead so it flows as a normal Result.Err.

Example

// Simple failure (halts the run)
fail("Something went wrong")

// Failure with structured details
fail("Validation failed", {"field": "email", "error": "invalid format"})

// Conditional failure
if(is-empty(users), fail("No users found"), first(users))

ns alias

Alias of ::hot::exec/

Execution control for runs and tasks.

Types

Cancellation core

Cancellation type {
    $msg: Str,
    $data: Any
}

Represents a cancelled execution. Produced by cancel() and surfaced as a run:cancel event.

Context-aware: ::hot::run/Cancellation when called in a run, ::hot::task/Cancellation when called in a task.

Fields:

  • $msg — short human-readable message.
  • $data — structured details (whatever was passed as the second cancel() argument).

cancel() halts execution; user code does not bind a Cancellation directly. Inspect it from a halt boundary like ::hot::lang/try-call or from the engine's run:cancel event.

Failure core

Failure type {
    $msg: Str,
    $err: Any
}

Represents a failed execution. Produced by fail() and surfaced as a run:fail event.

Context-aware: ::hot::run/Failure when called in a run, ::hot::task/Failure when called in a task.

Fields:

  • $msg — short human-readable message.
  • $err — structured details (whatever was passed as the second fail() argument).

fail() halts execution; user code does not bind a Failure directly. Inspect it from a halt boundary like ::hot::lang/try-call or from the engine's run:fail event.