http-exceptions
Raisable HTTP Exceptions
What it is and what it does
http-exceptions is a lightweight exception library that maps HTTP status codes to Python exception classes. Instead of manually catching errors and constructing HTTP responses, you raise semantic exceptions like ForbiddenException or BadRequestException directly from your business logic, and let your web framework handle the conversion to an HTTP response.
The package provides exception classes for all standard HTTP client errors (400–499) and server errors (500–599), organized into ClientException and ServerException base classes for hierarchical catching. It also supports dynamic exception lookup via HTTPException.from_status_code(), letting you raise the appropriate exception based on a status code at runtime. The single runtime dependency is importlib-metadata, and it supports Python 3.7 through 3.10.
Use it for:
- Raise ForbiddenException or UnauthorizedException from service functions without coupling to HTTP response objects
- Catch ClientException to handle all 4xx errors uniformly, or ServerException for all 5xx errors
- Convert an incoming HTTP response status code to the corresponding exception and re-raise it in your application
- Simplify FastAPI or other REST framework error handling by raising exceptions instead of returning error responses
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a set of raisable exception classes corresponding to HTTP status codes, allowing you to raise semantic HTTP errors directly from application code instead of manually constructing responses.
Yes, if you are building HTTP APIs and want to decouple business logic from HTTP response construction. The package is stable, has no known vulnerabilities, and low install friction. The main caveat is that the latest release is from 2022-02-15, so verify that it integrates well with your specific framework version before committing to it.
Install
http-exceptions on PyPI
pip
pip install http-exceptionsuv
uv add http-exceptionspoetry
poetry add http-exceptionsInstalling http-exceptions
Before you install
Low install friction with a single lightweight runtime dependency (importlib-metadata). The package is actively maintained with a recent commit on 2026-08-10, though the latest release dates to 2022-02-15.
License in practice
Licensed under MIT (permissive), so you can use it freely in commercial and open-source projects without copyleft obligations.
Quickstart
pip install http-exceptions
from http_exceptions import ForbiddenException, HTTPException
# Raise a specific exception
raise ForbiddenException()
# Or dynamically from a status code
raise HTTPException.from_status_code(status_code=403)(message="Access denied")
Verify before relying
- Whether the package's exception classes integrate seamlessly with popular frameworks like FastAPI, Django, or Starlette
- Whether custom message or metadata can be attached to exceptions beyond the status code
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.7,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — importlib-metadata |
| Maintenance | actively maintained — 1,641 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 283,513/month — #8,073 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: http_exceptions-0.2.10-py3-none-any.whl
Keywords: python, python3, http, exceptions, fastapi, api, web, rest
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
zExceptionszExceptions provides a collection of exception…
unclear · top 15,000 on PyPI
retryhttpRetryhttp wraps HTTP client calls to…
permissive · top 5,000 on PyPI
python-statusProvides named constants for HTTP status codes…
permissive · top 15,000 on PyPI
httsleephttsleep polls HTTP endpoints repeatedly until…
permissive · top 15,000 on PyPI
httmockIntercepts and mocks HTTP requests made by the…
permissive · top 5,000 on PyPI
fastapi-healthAdds a health check endpoint to FastAPI…
permissive · top 15,000 on PyPI
requestsexceptionsProvides a compatibility layer to import…
permissive · top 15,000 on PyPI
fastapi-decoratorsConverts functions into FastAPI-compatible…
permissive · top 15,000 on PyPI
exceptiongroupProvides exception group classes and utilities…
permissive · top 1,000 on PyPI
tuspyserverA FastAPI router that implements the tus…
unclear · top 15,000 on PyPI