A FastAPI middleware to prettify exceptions using PrettyErrors.
Project description
FastAPI PrettyErrors Middleware
A FastAPI middleware to prettify exceptions using PrettyErrors.
Installation
Install the package via pip:
pip install fastapi-pretty-errors
Or, if you’re using Poetry:
poetry add fastapi-pretty-errors
Usage
Add the middleware to your FastAPI application:
from fastapi import FastAPI
from fastapi_pretty_errors import PrettyErrorsMiddleware
app = FastAPI()
app.add_middleware(PrettyErrorsMiddleware)
Custom Configuration
You can specify custom configuration options for PrettyErrors when adding the middleware. Any keyword arguments passed to PrettyErrorsMiddleware will be forwarded to pretty_errors.configure() .
from fastapi import FastAPI
from fastapi_pretty_errors import PrettyErrorsMiddleware
app = FastAPI()
app.add_middleware(
PrettyErrorsMiddleware,
# PrettyErrors configuration options
display_locals=True,
line_number_first=True,
lines_before=5,
lines_after=2,
)
For a full list of configuration options, refer to the PrettyErrors documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_pretty_errors-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_pretty_errors-0.1.1.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
050a8f598ea7b3f71e630ab74701de8467ddb2dc79c466be9213749c9234d801
|
|
| MD5 |
08d488f3e8ad08dfd22dc9727c2a7c95
|
|
| BLAKE2b-256 |
3e28dc300d2167c367dffb1fb215a8ca22cd006078c4d88e930741e695b5f92b
|
File details
Details for the file fastapi_pretty_errors-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_pretty_errors-0.1.1-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Linux/6.5.0-1025-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1fdf6deeb79479ebe25c6fb53ed8eadf21b387fb105aff29cf3d9664aa12835
|
|
| MD5 |
83e2bf148616f0b432a2f0002066af54
|
|
| BLAKE2b-256 |
3832bbbd951f19758380b94c589ca405aeeb9ed1825860de7f99f03fbe607eb5
|