> ## Documentation Index
> Fetch the complete documentation index at: https://abxbus.archivebox.io/llms.txt
> Use this file to discover all available pages before exploring further.

# EventResult

> EventResult fields, status, and handler execution results.

Each handler execution for an event produces one `EventResult`.

You usually access results through `event.event_results` (or high-level event helper methods), but this page documents the underlying object.

## Common fields

* `id`: unique result id
* `status`: `pending | started | completed | error`
* `result`: handler return value (typed by event result schema/type)
* `error`: captured exception/error when handler fails
* `started_at`, `completed_at` (`None`/`null` until the handler starts/completes)
* `event_children`: child events emitted from inside this handler execution
* Handler metadata (`handler_id`, `handler_name`, `handler_file_path`, bus label/id/name)

## Await semantics

Awaiting an `EventResult` resolves to handler return value or raises captured failure in Python.
TypeScript and Go expose the stored result/error fields directly; Go's `Wait(...)` only waits for settlement.

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    entry = event.event_results[some_handler_id]
    value = await entry
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    const [, entry] = Array.from(event.event_results.entries())[0]
    const value = entry.result
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    for _, entry := range event.EventResults {
    	if err := entry.Wait(); err != nil {
    		return err
    	}
    	value := entry.Result
    	_ = value
    	break
    }
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let entry = event
        .event_results
        .read()
        .values()
        .next()
        .cloned()
        .expect("handler result");
    let value = entry.result.clone();
    ```
  </Tab>
</Tabs>

## Lifecycle

Every handler entry follows the same public lifecycle in each runtime:

1. `pending`: the event has accepted the handler result slot, but the handler has not started.
2. `started`: the handler callable is running.
3. `completed`: the handler returned a valid value or `None` / `null` / `nil`.
4. `error`: the handler raised, returned an invalid value, timed out, or was cancelled/aborted by completion policy.

Use `event.event_results` for the per-handler mapping and `event_result()` / `eventResult()` / `EventResult()` / `event_result().await` when you only need the first typed raw result value.

## Serialization

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    payload = entry.model_dump(mode='json')
    print(payload)
    # {
    #   "id": "0190...",
    #   "status": "completed",
    #   "event_id": "018f...",
    #   "handler_id": "018g...",
    #   "handler_name": "on_user_created",
    #   "result": {"user_id": "u_123"},
    #   "error": None,
    #   "...": "..."
    # }

    restored = EventResult.model_validate(payload)
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    const payload = entry.toJSON()
    console.log(payload)
    // {
    //   id: '0190...',
    //   status: 'completed',
    //   event_id: '018f...',
    //   handler: { id: '018g...', handler_name: 'onUserCreated', ... },
    //   result: { user_id: 'u_123' },
    //   error: undefined,
    //   ...
    // }

    const restored = EventResult.fromJSON(event, payload)
    ```
  </Tab>

  <Tab title="Go">
    ```go theme={null}
    payload, err := json.Marshal(entry)
    fmt.Println(string(payload))
    // {
    //   "id": "0190...",
    //   "status": "completed",
    //   "event_id": "018f...",
    //   "handler_id": "018g...",
    //   "handler_name": "on_user_created",
    //   "result": {"user_id": "u_123"},
    //   "error": null,
    //   ...
    // }

    restored, err := abxbus.EventResultFromJSON(payload)
    ```
  </Tab>

  <Tab title="Rust">
    ```rust theme={null}
    let payload = serde_json::to_value(&entry)?;
    println!("{}", serde_json::to_string_pretty(&payload)?);
    // {
    //   "id": "0190...",
    //   "status": "completed",
    //   "event_id": "018f...",
    //   "handler_id": "018g...",
    //   "handler_name": "on_user_created",
    //   "result": {"user_id": "u_123"},
    //   "error": null,
    //   ...
    // }

    let restored: abxbus::event_result::EventResult = serde_json::from_value(payload)?;
    ```
  </Tab>
</Tabs>
