Skip to content

Errors

Exception classes raised by flaude operations.

MachineExitError

MachineExitError(machine_id, exit_code, state, logs=None)

Bases: Exception

Raised when a Fly machine exits with a non-zero exit code or failure state.

Attributes:

Name Type Description
machine_id

The Fly machine ID.

exit_code

Process exit code (non-zero or None).

state

Final machine state (e.g. stopped, failed).

logs

Available log lines captured before/during failure. May be empty if no log drain was configured.

Source code in flaude/runner.py
def __init__(
    self,
    machine_id: str,
    exit_code: int | None,
    state: str,
    logs: list[str] | None = None,
):
    self.machine_id = machine_id
    self.exit_code = exit_code
    self.state = state
    self.logs = logs or []

    # Build message with log tail if available
    msg = f"Machine {machine_id} exited with code={exit_code} state={state}"
    if self.logs:
        # Include last N lines in the message for quick debugging
        tail = self.logs[-20:]
        log_text = "\n".join(tail)
        if len(self.logs) > 20:
            msg += f"\n\nLast 20 of {len(self.logs)} log lines:\n{log_text}"
        else:
            msg += f"\n\nCaptured {len(self.logs)} log lines:\n{log_text}"
    super().__init__(msg)

FlyAPIError

FlyAPIError(status_code, detail, method='', url='')

Bases: Exception

Raised when a Fly.io API call fails.

Source code in flaude/fly_client.py
def __init__(self, status_code: int, detail: str, method: str = "", url: str = ""):
    self.status_code = status_code
    self.detail = detail
    self.method = method
    self.url = url
    super().__init__(f"Fly API error {status_code} {method} {url}: {detail}")