Common exceptions for FastAPI
Project description
FastAPI exceptions
Introduction
fastapi-exceptions
is a set of standard http exceptions based on starlette exceptions.
Installation
> pip install fastapi-exceptions
Usage
Instead of duplication of exceptions codes and their details for standard cases:
from fastapi import HTTPException
from starlette import status
# some app logic ...
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail='Authentication credentials were not provided',
)
you can simply import exceptions and use wherever you need:
from fastapi_exceptions.exceptions import NotAuthenticated
# some app logic ...
raise NotAuthenticated()
and, of course, modify details if needed:
# some app logic ...
raise NotAuthenticated(detail='No authentication header')
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
Close
Hashes for fastapi_exceptions-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52cdaa82183a8cb861e2930896e763b46c314249f1b300495278134036d91de7 |
|
MD5 | 180d4bb90a974648a2cab51c0836eb90 |
|
BLAKE2b-256 | c823c2a8f52428a0fddd2bc1907d802d4025cd08744ae92a1076d4ee459603d0 |