--- id: http-exceptions version: "0.2.10" license: MIT license_treatment: permissive maintenance: active --- # http-exceptions — Raisable HTTP Exceptions License: permissive · Maintenance: active · Downloads: 283.5K/mo ## 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 above — 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 pip install http-exceptions uv add http-exceptions poetry add http-exceptions ## Installing 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_current - Install friction: low - Maintenance: active - Downloads: 283.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags http status code exceptions, raise http errors in python, http exception classes, fastapi exception handling, rest api error responses, semantic http exceptions, 400 500 status exceptions, http-errors, exception-handling, rest-api [View on SkillFed](https://skillfed.io/packages/http-exceptions) · [View on PyPI](https://pypi.org/project/http-exceptions/)