Skip to content

spark_on_k8s.api.utils

Implementation reference. These symbols describe how the project works; their presence here does not make them supported application imports. Use the documented entry points and support policy.

error_body(code, message)

The API's single error envelope, shared with the versioned /jobs/v1 contract.

Source code in spark_on_k8s/api/utils.py
37
38
39
def error_body(code: str, message: str) -> dict:
    """The API's single error envelope, shared with the versioned /jobs/v1 contract."""
    return {"schema_version": 1, "error": {"code": code, "message": message}}

install_error_handlers(app)

Serialize every HTTP error, including framework routing and validation errors, alike.

Source code in spark_on_k8s/api/utils.py
89
90
91
92
93
def install_error_handlers(app: FastAPI) -> None:
    """Serialize every HTTP error, including framework routing and validation errors, alike."""
    app.add_exception_handler(HTTPException, _http_error)
    app.add_exception_handler(RequestValidationError, _validation_error)
    app.add_exception_handler(Exception, _unexpected_error)