Current collected state Current
Observed since 20 Oct, 17:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Shared base exception utilities for FastAPI apps.
A comprehensive exception handling package for FastAPI applications that provides standardized error responses and exception handling.
pip install abs-exception-core
from fastapi import FastAPI
from abs_exception_core.exception_handlers import (
request_validation_exception_handler,
global_exception_handler,
# ... other handlers
)
app = FastAPI()
# Register exception handlers
app.add_exception_handler(RequestValidationError, request_validation_exception_handler)
app.add_exception_handler(Exception, global_exception_handler)
from abs_exception_core.exceptions import (
NotFoundError,
ValidationError,
AuthError,
GenericHttpError,
# ... other exceptions
)
# Example usage in a route
@app.get("/items/{item_id}")
async def get_item(item_id: int):
if not item_exists(item_id):
raise NotFoundError(detail="Item not found")
if not has_permission():
raise AuthError(detail="Insufficient permissions")
The GenericHttpError class allows you to create custom HTTP exceptions with any status code:
# Create a custom error with status code 418
error = GenericHttpError(
status_code=418,
detail="I'm a teapot",
headers={"X-Custom-Header": "value"}
)
# Create a custom error with just status code and message
error = GenericHttpError(
status_code=451,
detail="Unavailable For Legal Reasons"
)
# Create a custom error with just status code
error = GenericHttpError(status_code=402)
DuplicatedError (409 Conflict)AuthError (403 Forbidden)NotFoundError (404 Not Found)ValidationError (422 Unprocessable Entity)PermissionDeniedError (403 Forbidden)UnauthorizedError (401 Unauthorized)BadRequestError (400 Bad Request)ConflictError (409 Conflict)InternalServerError (500 Internal Server Error)RateLimitExceededError (429 Too Many Requests)ServiceUnavailableError (503 Service Unavailable)GenericHttpError (Custom Status Code) - For creating custom HTTP exceptionsAll errors follow a standardized format:
{
"message": "Error message",
"error": "Detailed error description",
"type": "ErrorType",
"details": {
"path": "/api/endpoint",
"method": "GET"
},
"errors": [
{
"field": "field_name",
"message": "Validation message",
"type": "error_type",
"input_value": "invalid_value"
}
]
}
GenericHttpErrorThis project is licensed under the MIT License - see the LICENSE file for details.
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.3.1 | 12 Mar 2026 | 2 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 17:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:5d6af7fa7a10558e68c895424ae4495dff8c0843144bbbdc7e3d616d53e05578