This release is a pre-release and may not be stable for production use.
Swarmauri Middleware Exception Handling
Centralized exception and error handling for Swarmauri applications built on FastAPI.
Features
- Wraps unhandled exceptions in a consistent JSON payload with the error type, message, and a UTC timestamp.
- Logs request metadata (method, path, and headers) alongside the stack trace to simplify troubleshooting.
- Registers through the Swarmauri component system and can be attached to any
FastAPI application via
app.middleware("http").
Installation
Pick the workflow that matches your project:
pip install swarmauri_middleware_exceptionhandling
poetry add swarmauri_middleware_exceptionhandling
uv pip install swarmauri_middleware_exceptionhandling
# or, inside a uv project
uv add swarmauri_middleware_exceptionhandling
Usage
Attach the middleware to convert uncaught exceptions into the structured error response returned by Swarmauri services.
from fastapi import FastAPI
from fastapi.testclient import TestClient
from swarmauri_middleware_exceptionhandling import ExceptionHandlingMiddleware
app = FastAPI()
app.middleware("http")(ExceptionHandlingMiddleware())
@app.get("/boom")
async def boom():
raise RuntimeError("Boom!")
client = TestClient(app)
response = client.get("/boom")
assert response.status_code == 500
print(response.json())
The JSON payload produced by the middleware includes the error type, message, and a timestamp similar to the following:
{
"error": {
"type": "Unhandled Exception",
"message": "Boom!",
"timestamp": "2024-05-01T12:34:56.789012"
}
}
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
Metadata
Release files for swarmauri_middleware_exceptionhandling 0.11.0.dev1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| swarmauri_middleware_exceptionhandling-0.11.0.dev1.tar.gz | 7.6 kB | Without provenance | Details for swarmauri_middleware_exceptionhandling-0.11.0.dev1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| swarmauri_middleware_exceptionhandling-0.11.0.dev1-py3-none-any.whl | Python 3 | none | any | Details for swarmauri_middleware_exceptionhandling-0.11.0.dev1-py3-none-any.whl |
Total release size: 16.3 kB
Release files / swarmauri_middleware_exceptionhandling-0.11.0.dev1.tar.gz
| Download URL | swarmauri_middleware_exceptionhandling-0.11.0.dev1.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0176e09b9a0f198b5612fd5152ab50976ac79f2d7a1de544c2ab3947cd6b311a
|
|
BLAKE2b-256 checksum How to use checksums |
94b733a99b15e03ee6af070c5a38575d560e3e9f03ec525fa74bab7729c99eb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_middleware_exceptionhandling-0.11.0.dev1-py3-none-any.whl
| Download URL | swarmauri_middleware_exceptionhandling-0.11.0.dev1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
97e14ccb409d31b54aec32e7c2a3adaec81169be0d4f15ba3b03d26bb707daf9
|
|
BLAKE2b-256 checksum How to use checksums |
5824719b6ee84b55707062b6cf6e2e61c4d72aa2c19ead2e03b24843cf0c9ca4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for swarmauri_middleware_exceptionhandling 0.11.0.dev1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.