No project description provided
Project description
fast exception
This package is a plugin for easier handling of Exception and sending HTTP status code.
Installing
pip install fastexception
Usage
You can use FastAPI itself as follows:
@app.get("/")
def index(password: str):
if password.validate():
raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail="message")
status code : 400
message : message
But the simpler and more readable way to use fastexception is as follows:
@app.get("/")
def index(password: str):
if password.validate():
FastException.HTTP_400_BAD_REQUEST.http("message")
status code : 400
message : message
You can write your desired message in http, if you don't write it, fastexception will show the appropriate message.
@app.get("/")
def index(password: str):
if password.validate():
FastException.HTTP_400_BAD_REQUEST.http()
status code : 400
message : Bad Request
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
fastexception-0.1.2.tar.gz
(1.6 kB
view details)
File details
Details for the file fastexception-0.1.2.tar.gz
.
File metadata
- Download URL: fastexception-0.1.2.tar.gz
- Upload date:
- Size: 1.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4612e73057331db803bf22b23326857ce85ddd9be6f9c6d51b6cb953acd311 |
|
MD5 | 0af3895cb2b91d7ac0ff9ce080102567 |
|
BLAKE2b-256 | c54bcffa5f48911cdf27fd7031e42b7c1b549dd85ee9cd6b1c290805ad20694d |