Light Dark

Functions

cancel core

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

Cancel the current execution. Halts execution gracefully.

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

Example

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

// Cancellation with data
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

Fail with err or msg and err. Halts execution immediately.

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

Example

// Simple failure
fail("Something went wrong")

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

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

Types

Cancellation core

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

Represents a cancelled execution. Created by cancel().

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

Example

c cancel("User cancelled", {"reason": "timeout"})
c.$msg    // "User cancelled"
c.$data   // {"reason": "timeout"}

Failure core

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

Represents a failed execution. Created by fail().

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

Example

f fail("Connection failed", {"host": "api.example.com"})
f.$msg   // "Connection failed"
f.$err   // {"host": "api.example.com"}