Skip to main content

RFC9457 compliant problem details for HCLI applications

Project description

pypi pyver

hcli_problem_details

A Python library providing RFC 9457 compliant problem detail exceptions for HCLI applications and other Python projects.


This package delivers a complete set of HTTP problem detail exceptions adhering to RFC 9457 (Problem Details for HTTP APIs). Built as part of the HCLI ecosystem, it offers reusable exception classes for HTTP 4xx and 5xx status codes, simplifying standardized error handling in HCLI applications and other Python projects. Each exception can be transformed into an RFC 9457 compliant problem detail dictionary for consistent API error responses.

Learn more about HCLI at hcli.io [1].

Help shape this library and the HCLI ecosystem by raising issues on GitHub!

[1] http://hcli.io

Installation

hcli_problem_details requires a supported version of Python and pip.

pip install hcli-problem-details

Usage

Import and raise exceptions in your Python application as needed. Each exception generates an RFC 9457 compliant problem detail representation.

from hcli_problem_details import NotFoundError, BadRequestError

# Raise a 404 Not Found error
raise NotFoundError(detail="Resource not found")
# Output: {"type": "about:blank", "title": "Not Found", "status": 404, "detail": "Resource not found"}

# Raise a 400 Bad Request error with custom extensions
raise BadRequestError(detail="Invalid input", extensions={"field": "username"})
# Output: {"type": "about:blank", "title": "Bad Request", "status": 400, "detail": "Invalid input", "field": "username"}

Integration with HCLI Core

HCLI Core utilizes this package to automatically recognize and relay its raised exceptions to HCLI clients (e.g., huckle) as problem details.

Versioning

This project follows semantic versioning (http://semver.org). Development releases may use “devx”, “prealphax”, “alphax”, “betax”, or “rcx” extensions (e.g., 0.1.0-prealpha1) on GitHub. Only full major.minor.patch releases are published to PyPI.

Supports

  • Full coverage of HTTP 4xx client errors and 5xx server errors as exception classes.

  • RFC 9457 problem detail structure with type, title, status, detail, instance, and extensible extensions.

  • Compatibility with HCLI Core and any Python project requiring standardized HTTP error handling.

To Do

  • Add automated tests for all exception classes.

  • Provide integration examples for common web frameworks (e.g., Flask, FastAPI, Falcon).

  • Document advanced usage of extensions for custom problem details.

Bugs

  • No known issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hcli_problem_details-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hcli_problem_details-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file hcli_problem_details-0.1.0.tar.gz.

File metadata

  • Download URL: hcli_problem_details-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.11

File hashes

Hashes for hcli_problem_details-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9ee295e3bad4c1a291ab33092ce82d78b8d8d93b6857e9692cc542860fed7071
MD5 50c2f1704fd1e31f823f9c9bd43b11ec
BLAKE2b-256 54e48c42069f7a9db9f5e59fad8566befb28c37dd7be548d64838bb5a00dda69

See more details on using hashes here.

File details

Details for the file hcli_problem_details-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hcli_problem_details-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 666ef1adfa994badd023113fde13c3647bf1774e1e8a83ab33f4412fca48aae2
MD5 cb3db68a2208c61ead3e39d1f4b64902
BLAKE2b-256 7f1ca8293ff8ef3ffb44eb342b5700920a34bb1e5f83495be193dde648d42fef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page