Documentation
¶
Overview ¶
Package problem decodes the Normatik public API's RFC-7807 ProblemDetail responses and maps them to actionable CLI output + exit codes.
Design choice (the CLI's value-add): we decode the RAW error body into a generic map so that EVERY field — including hint fields the CLI does not yet know about — is preserved (Raw). Known fields are additionally lifted into typed fields for ergonomic access. Exit-code policy lives in one place (internal/catalog.ExitFor); the synthesized "next command" is a data-driven registry keyed by errorCode rather than a growing switch.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diagnostic ¶
type Problem ¶
type Problem struct {
Status int
Title string
Detail string
ErrorCode string
Hint string
Reason string
ValidKeys []string
ValidNames []string
InvalidKeys []string
UnknownKeys []string
ValidValues []string
AllowedMethods []string
CurrentStatus string
RequestedAction string
RequiredRole string
Field string
ReceivedValue string
MinValue string
MaxValue string
ReceivedZone string
EntityType string
CurrentVersion string
UsageCount *int
// RetryAfterSeconds and InTrash drive recovery suggestions.
RetryAfterSeconds *int
InTrash bool
Diagnostics []Diagnostic
Raw map[string]json.RawMessage
}
Problem is a decoded ProblemDetail. Known fields are typed; Raw holds every field verbatim for forward-compatible surfacing.
func Decode ¶
Decode parses an error body. ok=false means the body is NOT a recognizable ProblemDetail (e.g. a Tomcat HTML 404) — callers treat that as a distinct "malformed backend response" class instead of pretending it has an errorCode.
func (*Problem) ExitCode ¶
ExitCode maps a problem to a stable, documented exit code (see `explain exit-codes`). The policy is centralized in catalog.ExitFor so the CLI and the generated catalogue can never disagree. Agents branch on the exit code first, then on the errorCode for precision.
func (*Problem) Suggestion ¶
Suggestion synthesizes a runnable "next command" from the structured hint fields, so an agent (or human) can self-correct in one loop.