FastAPI Exception
Installation
pip install fastapi-exception
How to use
fastapi_exception exposes exceptions
- FastApiException
- ForbiddenException
- NotFoundException
- GoneException
- BadRequestException
- DirectResponseException
- EntityNotFoundException
- UnauthorizedException
fastapi_exception exposes errors
- DuplicateError
- StringTooLongError
- StringTooShortError
- MissingError
Configuration
# config/exception.py
from config.i18n import i18n_service
from fastapi_exception import FastApiException
FastApiException.init()
FastApiException.init(translator_service=i18n_service) # pass translator_service if we integrate with i18n
Use exceptions with throw_validation
from fastapi_exception import throw_validation
throw_validation(type='value_error', loc=('body', 'key'))
Use errors with throw_validation_with_exception
from fastapi_exception import throw_validation_with_exception, MissingError
raise throw_validation_with_exception(MissingError(('body', 'product media or galleries')))
Customize Exception
from fastapi_exception import ValidationErrorDetail
class InvalidDataTypeError(ValidationErrorDetail):
error_type = 'datatype.invalid'
def __init__(
self,
loc: tuple[int | str, ...],
ctx: dict[str, dict[str, Any]] | None = {},
input: dict[str, Any] = {},
):
super().__init__(self.error_type, loc, '', input, ctx)
throw_validation_with_exception(InvalidDataTypeError(('body', 'value')))
Metadata
Release files for fastapi-exception 1.3.10
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 |
|---|---|---|---|---|
| fastapi_exception-1.3.10.tar.gz | 11.3 kB | Without provenance | Details for fastapi_exception-1.3.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_exception-1.3.10-py3-none-any.whl | Python 3 | none | any | Details for fastapi_exception-1.3.10-py3-none-any.whl |
Total release size: 25.2 kB
Release files / fastapi_exception-1.3.10.tar.gz
| Download URL | fastapi_exception-1.3.10.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7849ab9853d3c46c1cb48eda1ff63574eabaa59ff220ff6f8a80cf23d101eee
|
|
BLAKE2b-256 checksum How to use checksums |
605be0b72e308321ce4b763b4a0ea258cc010ebd96ea6d1c78c551c7c9930094
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Release files / fastapi_exception-1.3.10-py3-none-any.whl
| Download URL | fastapi_exception-1.3.10-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a66705cb84e2bb38a64f4b05229a02caa8368855bd84398db4ce6496e96d4895
|
|
BLAKE2b-256 checksum How to use checksums |
e153158f83e20f8ea1e434eb90e0ec90cc061ce04c24d16cb60600777533b953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.10.14
|
Security for fastapi-exception 1.3.10
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.