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
File details
Details for the file fastapi_pretty_errors-0.1.0.tar.gz
.
File metadata
- Download URL: fastapi_pretty_errors-0.1.0.tar.gz
- Upload date:
- Size: 2.5 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 | 4d7136bf7250d734e1bfa73fd559b8c5aa656f83c3e6320d3b991a7b8575c426 |
|
MD5 | 0a7058f736f7c7303917bdf195fd0326 |
|
BLAKE2b-256 | 0a52ac0080213a30a7b39919bec46d18c73ff1e80d87c1fe8c332fd1e366c231 |
File details
Details for the file fastapi_pretty_errors-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: fastapi_pretty_errors-0.1.0-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 | d4fe79a2dc8155f1c20f667ca27d0746176f13d43eaed157789bcc8172ee0af5 |
|
MD5 | c422d995ae6dafc669e944623b629a51 |
|
BLAKE2b-256 | 887e84edddf42fcaca1a5b8325c60522d7890f17c36e626d119b066db2e6011d |