labthings_fastapi.problem_details
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
Classes
A model to describe an error that occurred in an invocation. |
Functions
|
Return a URL identifying a LabThings exception. |
Module Contents
- class labthings_fastapi.problem_details.ProblemDetails(/, **data: Any)
Bases:
pydantic.BaseModelA 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.selfis explicitly positional-only to allowselfas a field name.- model_config
Configuration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].
- classmethod from_exception(exc: BaseException) Self
Generate a
ProblemDetailsmodel from an exception instance.- Parameters:
exc – the exception instance to be described.
- Returns:
a
ProblemDetailsobject describingexc.
- labthings_fastapi.problem_details.DOCS_URL = 'https://labthings-fastapi.readthedocs.io/en/latest/autoapi/labthings_fastapi/exceptions/index.html'
- labthings_fastapi.problem_details.PYTHON_DOCS_URL = 'https://docs.python.org/3/library/exceptions.html'