Skip to content

Module stac_fastapi.core.exceptions

Custom exceptions for STAC FastAPI.

Provides exception classes and FastAPI-compatible handlers for scenarios that require non-standard HTTP responses (e.g., 202 Accepted for background-queue operations).

Functions

queued_success_handler

def queued_success_handler(
    request: starlette.requests.Request,
    exc: stac_fastapi.core.exceptions.QueuedSuccess
) -> starlette.responses.JSONResponse

Catch :class:QueuedSuccess and format it as a 202 Accepted response.

Parameters:

Name Type Description Default
request None The current FastAPI request. None
exc None The :class:QueuedSuccess exception carrying the response payload. None

Returns:

Type Description
None A JSONResponse with status code 202 and the queued payload.

Classes

QueuedSuccess

class QueuedSuccess(
    payload: dict | str
)

Raised when an item is successfully pushed to the background queue.

The payload attribute contains the response body that the FastAPI exception handler should serialize as a 202 Accepted JSON response.

Ancestors (in MRO)

  • builtins.Exception
  • builtins.BaseException

Class variables

args

Methods

add_note

def add_note(
    ...
)

Exception.add_note(note) --

add a note to the exception

with_traceback

def with_traceback(
    ...
)

Exception.with_traceback(tb) --

set self.traceback to tb and return self.