skillfed

http-exceptions

Raisable HTTP Exceptions

http-exceptions v0.2.10 283.5K downloads/30d#8,073 on PyPI3
Permissive license MIT Active released

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-exceptions

uv

uv add http-exceptions

poetry

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 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Build ToolsTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

http status code exceptionsraise http errors in pythonhttp exception classesfastapi exception handlingrest api error responsessemantic http exceptions400 500 status exceptions
http-errorsexception-handlingrest-api

More Python Modules packages