Skip to content

ump_spec.errors

module ump-spec

Typed UMP error with RFC 9457 conversion. Codes and HTTP statuses come from registries/error_codes.yaml (spec §19 and §25.4). Each code has exactly one status: a code whose registered status is an error status (400 or above) always takes it, whatever status= says; only a note code raised as a stop (registered 200) takes the caller’s status, and an unregistered code keeps the status it was given (400 by default).

Documented on the page of the module that defines them.

NameKindSummary
PROBLEM_BASEconstantSpec §19 problem type base (fixed at publication, §24).
problem_typefunctionSpec §19: the one registered type URI of a code (base + lower case, underscores to hyphens).

class

class UmpError(Exception)

Raise anywhere; convert with to_problem(); the SDK app factory renders it.

Fields

NameTypeDefaultDescription
codecode
detaildetail or info.get('title', code)
statusstatus or registered
titleinfo.get('title', code.replace('_', ' ').title())
pointerpointer
suggested_actionsuggested_action or info.get('suggested_action')
untrusted_textuntrusted_text
gate_idgate_id or gate
errorserrors or []
fallbacksfallbacks or []
extraextra or {}
Methods and properties (3)

init constructor

UmpError(
self,
code: str,
detail: str = '',
*,
status: int | None = None,
pointer: str | None = None,
suggested_action: str | None = None,
untrusted_text: str | None = None,
gate_id: str | None = None,
gate: str | None = None,
errors: list[ProblemIssue] | None = None,
fallbacks: list[FallbackEntry] | None = None,
extra: dict[str, Any] | None = None,
) -> None

gate property

gate: str | None

Python alias of gate_id (the wire member is gate_id, spec §19).

to_problem method

def to_problem(self, *, instance: str | None = None) -> Problem

Source: packages/ump-spec/src/ump_spec/errors.py, line 16

function

def problem(code: str, detail: str = '', **kw: Any) -> Problem

Source: packages/ump-spec/src/ump_spec/errors.py, line 77