problem

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package problem implements application/problem+json (RFC 9457) errors with the OBX error codes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Status

func Status(code string) int

Status returns the HTTP status for an OBX error code.

func Write

func Write(w http.ResponseWriter, p *Problem)

Write sends the problem as the response.

Types

type FieldError

type FieldError struct {
	Pointer  *string `json:"pointer"`
	ObxError string  `json:"obx_error"`
	Detail   string  `json:"detail"`
}

FieldError is one entry of Problem.errors.

type Problem

type Problem struct {
	Type       string       `json:"type"`
	Title      string       `json:"title"`
	Status     int          `json:"status"`
	Detail     *string      `json:"detail"`
	Instance   *string      `json:"instance,omitempty"`
	ObxError   string       `json:"obx_error"`
	Errors     []FieldError `json:"errors,omitempty"`
	RetryAfter *int         `json:"retry_after,omitempty"`
}

Problem is the error document.

func As

func As(err error) *Problem

As converts any error to a problem (unknown errors become internal_error without leaking details).

func New

func New(code, format string, args ...any) *Problem

New creates a problem for code with a detail message.

func (*Problem) Error

func (p *Problem) Error() string

func (*Problem) Field

func (p *Problem) Field(pointer, code, detail string) *Problem

Field adds a field error (pointer may be "").

func (*Problem) WithStatus

func (p *Problem) WithStatus(s int) *Problem

WithStatus overrides the HTTP status (setup_required is 409 or 503).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL