Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi-exceptions-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

fastapi_exceptions-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi-exceptions-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi-exceptions-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for fastapi-exceptions-0.1.0.tar.gz
Algorithm Hash digest
SHA256 973409cbd145293746f75e9e6711a30997d5165ff2e4dddb4c28e09562d819f6
MD5 20009110f7d34a45cff7362fac1320ce
BLAKE2b-256 93b1d96b5f4f42b978934698789fe147ec7fe77ee9355b172366fad101deede8

See more details on using hashes here.

File details

Details for the file fastapi_exceptions-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_exceptions-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 52cdaa82183a8cb861e2930896e763b46c314249f1b300495278134036d91de7
MD5 180d4bb90a974648a2cab51c0836eb90
BLAKE2b-256 c823c2a8f52428a0fddd2bc1907d802d4025cd08744ae92a1076d4ee459603d0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page