labthings_fastapi.problem_details ================================= .. py:module:: labthings_fastapi.problem_details .. autoapi-nested-parse:: JSON representations of errors as per RFC 9457. This module defines a model and supporting functions that help to create "Problem Details" objects to represent errors in HTTP responses. Attributes ---------- .. autoapisummary:: labthings_fastapi.problem_details.DOCS_URL labthings_fastapi.problem_details.PYTHON_DOCS_URL Classes ------- .. autoapisummary:: labthings_fastapi.problem_details.ProblemDetails Functions --------- .. autoapisummary:: labthings_fastapi.problem_details.docs_url Module Contents --------------- .. py:class:: ProblemDetails(/, **data: Any) Bases: :py:obj:`pydantic.BaseModel` A model to describe an error that occurred in an invocation. Create a new model by parsing and validating input data from keyword arguments. Raises [`ValidationError`][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model. `self` is explicitly positional-only to allow `self` as a field name. .. py:attribute:: model_config Configuration for the model, should be a dictionary conforming to [`ConfigDict`][pydantic.config.ConfigDict]. .. py:attribute:: detail :type: str | None :value: None A human-readable string with details of the error. .. py:attribute:: type :type: str | None :value: None A URI giving a unique reference for the error. .. py:attribute:: status :type: int | None :value: None An HTTP status code describing the error. .. py:attribute:: title :type: str | None :value: None A human-readable title for the error. .. py:attribute:: instance :type: str | None :value: None A URI that may or may not give details about this specific instance. .. py:method:: from_exception(exc: BaseException) -> Self :classmethod: Generate a `ProblemDetails` model from an exception instance. :param exc: the exception instance to be described. :return: a `ProblemDetails` object describing ``exc``\ . .. py:data:: DOCS_URL :value: 'https://labthings-fastapi.readthedocs.io/en/latest/autoapi/labthings_fastapi/exceptions/index.html' .. py:data:: PYTHON_DOCS_URL :value: 'https://docs.python.org/3/library/exceptions.html' .. py:function:: docs_url(exc: type[BaseException]) -> str | None Return a URL identifying a LabThings exception. :param exc: An exception class. :return: a URL pointing to that exception in the docs, or `None` if the exception is not in this module.