fal.exceptions package

Submodules

fal.exceptions.auth module

exception fal.exceptions.auth.UnauthenticatedException

Bases: FalServerlessException

fal.exceptions.gpu module

exception fal.exceptions.gpu.CUDAOutOfMemoryException(message='CUDA error: out of memory', status_code=503)

Bases: GPUOutOfMemoryException

Exception raised when a CUDA operation runs out of memory.

message: str = 'CUDA error: out of memory'
exception fal.exceptions.gpu.GPUException(message='GPU error', status_code=503)

Bases: AppException

Base exception for GPU-related errors.

message: str = 'GPU error'
status_code: int = 503
exception fal.exceptions.gpu.GPUOutOfMemoryException(message='GPU error', status_code=503)

Bases: GPUException

Exception raised when a GPU operation runs out of memory.

class fal.exceptions.gpu.catch_gpu_exceptions

Bases: ContextDecorator

Catch GPU/CUDA exceptions and convert them to HTTP 503 responses.

Works as both a context manager and a decorator. Any caught GPU exception (CUDA OOM, cuDNN errors, NVML failures, etc.) is re-raised as a GPU exception with HTTP status 503.

Raises:

Example

from fal.exceptions import catch_gpu_exceptions

with catch_gpu_exceptions():

run_inference()

@catch_gpu_exceptions() def run_inference():

Note

The 503 status code signals the platform to restart the runner.

Module contents

exception fal.exceptions.AppException(message, status_code)

Bases: FalServerlessException

Base exception class for application-specific errors.

message

A descriptive message explaining the error.

status_code

The HTTP status code associated with the error.

message: str
status_code: int
exception fal.exceptions.AppFileUploadException(message, relative_path)

Bases: FalServerlessException

Raised when file upload fails

message: str
relative_path: str
exception fal.exceptions.CUDAOutOfMemoryException(message='CUDA error: out of memory', status_code=503)

Bases: GPUOutOfMemoryException

Exception raised when a CUDA operation runs out of memory.

message: str = 'CUDA error: out of memory'
exception fal.exceptions.FalServerlessException

Bases: Exception

Base exception type for fal Serverless related flows and APIs.

exception fal.exceptions.FieldException(field, message, status_code=422, type='value_error', billable_units=0)

Bases: FalServerlessException

Exception raised for errors related to specific fields.

field

The field that caused the error.

message

A descriptive message explaining the error.

status_code

The HTTP status code associated with the error. Defaults to 422

type

The type of error. Defaults to “value_error”

billable_units: int | float | str | None = 0
field: str
message: str
status_code: int = 422
to_pydantic_format()
Return type:

dict[str, list[dict]]

type: str = 'value_error'
exception fal.exceptions.FileTooLargeError(message='File is too large.')

Bases: FalServerlessException

Exception raised when the file is too large.

message: str = 'File is too large.'
exception fal.exceptions.GPUException(message='GPU error', status_code=503)

Bases: AppException

Base exception for GPU-related errors.

message: str = 'GPU error'
status_code: int = 503
exception fal.exceptions.GPUOutOfMemoryException(message='GPU error', status_code=503)

Bases: GPUException

Exception raised when a GPU operation runs out of memory.

exception fal.exceptions.RequestCancelledException(message='Request cancelled by the client.')

Bases: FalServerlessException

Exception raised when the request is cancelled by the client.

message: str = 'Request cancelled by the client.'
exception fal.exceptions.UnauthenticatedException

Bases: FalServerlessException

class fal.exceptions.catch_gpu_exceptions

Bases: ContextDecorator

Catch GPU/CUDA exceptions and convert them to HTTP 503 responses.

Works as both a context manager and a decorator. Any caught GPU exception (CUDA OOM, cuDNN errors, NVML failures, etc.) is re-raised as a GPU exception with HTTP status 503.

Raises:

Example

from fal.exceptions import catch_gpu_exceptions

with catch_gpu_exceptions():

run_inference()

@catch_gpu_exceptions() def run_inference():

Note

The 503 status code signals the platform to restart the runner.