# Error Handling

Scalar UDFs can also set `@geneva.udf(timeout=...)` to enforce a per-row timeout in
seconds. Timeout failures surface as ordinary `TimeoutError`, so existing
`on_error`, retry, and `skip_on_error()` behavior applies unchanged.

This timeout support is scalar-only and uses Unix `SIGALRM` / `setitimer`
semantics at runtime. It also requires execution on the worker process main
thread. It works inside `MultiProcessBatchApplier` worker subprocesses because
each child executes batches on its own main thread, but it still uses
process-global signal state. UDFs or libraries that install their own
`SIGALRM` handlers/timers, or that depend on main-thread signal behavior while
coordinating work in background threads, may be incompatible.

## Fatal Worker Errors

Scalar UDF backfill also classifies fatal worker loss into public Geneva
exception types:

- `FatalWorkerTransientError`
- `FatalWorkerOOMError`
- `FatalWorkerCrashError`
- `FatalWorkerExitError`

By default, `FatalWorkerTransientError` is retried up to 3 task-level attempts,
even if the user does not specify an `on_error` policy.

If the user provides `on_error` and does **not** explicitly match
`FatalWorkerTransientError`, Geneva still applies that default retry behavior.
If the user **does** explicitly match it, the user configuration wins.

Examples:

```python
from geneva import Retry, Fail, udf
from geneva.errors import FatalWorkerTransientError

@udf(
    data_type=pa.int64(),
    on_error=[Retry(FatalWorkerTransientError, max_attempts=5)],
)
def retry_infra_failures(x: int) -> int:
    return x * 2


@udf(
    data_type=pa.int64(),
    on_error=[Fail(FatalWorkerTransientError)],
)
def fail_on_infra_failures(x: int) -> int:
    return x * 2
```

## Exception Matchers

::: geneva.debug.error_store.Retry

::: geneva.debug.error_store.Skip

::: geneva.debug.error_store.Fail

## Helper Functions

::: geneva.debug.error_store.retry_transient

::: geneva.debug.error_store.retry_all

::: geneva.debug.error_store.skip_on_error

::: geneva.debug.error_store.fail_fast

## Configuration

::: geneva.debug.error_store.ErrorHandlingConfig

::: geneva.debug.error_store.UDFRetryConfig

::: geneva.debug.error_store.ErrorRecord
