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:
GPUOutOfMemoryExceptionException raised when a CUDA operation runs out of memory.
-
message:
str= 'CUDA error: out of memory'¶
-
message:
- exception fal.exceptions.gpu.GPUException(message='GPU error', status_code=503)¶
Bases:
AppExceptionBase exception for GPU-related errors.
-
message:
str= 'GPU error'¶
-
status_code:
int= 503¶
-
message:
- exception fal.exceptions.gpu.GPUOutOfMemoryException(message='GPU error', status_code=503)¶
Bases:
GPUExceptionException raised when a GPU operation runs out of memory.
- class fal.exceptions.gpu.catch_gpu_exceptions¶
Bases:
ContextDecoratorCatch 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:
CUDAOutOfMemoryException – When a CUDA OOM error is caught.
GPUException – When a generic GPU-related error is caught.
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:
FalServerlessExceptionBase 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:
FalServerlessExceptionRaised when file upload fails
-
message:
str¶
-
relative_path:
str¶
-
message:
- exception fal.exceptions.CUDAOutOfMemoryException(message='CUDA error: out of memory', status_code=503)¶
Bases:
GPUOutOfMemoryExceptionException raised when a CUDA operation runs out of memory.
-
message:
str= 'CUDA error: out of memory'¶
-
message:
- exception fal.exceptions.FalServerlessException¶
Bases:
ExceptionBase 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:
FalServerlessExceptionException 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:
FalServerlessExceptionException raised when the file is too large.
-
message:
str= 'File is too large.'¶
-
message:
- exception fal.exceptions.GPUException(message='GPU error', status_code=503)¶
Bases:
AppExceptionBase exception for GPU-related errors.
-
message:
str= 'GPU error'¶
-
status_code:
int= 503¶
-
message:
- exception fal.exceptions.GPUOutOfMemoryException(message='GPU error', status_code=503)¶
Bases:
GPUExceptionException raised when a GPU operation runs out of memory.
- exception fal.exceptions.RequestCancelledException(message='Request cancelled by the client.')¶
Bases:
FalServerlessExceptionException raised when the request is cancelled by the client.
-
message:
str= 'Request cancelled by the client.'¶
-
message:
- exception fal.exceptions.UnauthenticatedException¶
Bases:
FalServerlessException
- class fal.exceptions.catch_gpu_exceptions¶
Bases:
ContextDecoratorCatch 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:
CUDAOutOfMemoryException – When a CUDA OOM error is caught.
GPUException – When a generic GPU-related error is caught.
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.