operr

package
v0.1.39 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package operr provides marker errors that classify operation failures so HTTP handlers can map them to status codes with errors.Is instead of matching message strings (which silently broke whenever a message was reworded). The markers never appear in the error text.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("not found")     // a referenced resource does not exist -> 404
	ErrConflict  = errors.New("conflict")      // the resource already exists / is in use -> 409
	ErrInvalid   = errors.New("invalid input") // the request cannot be satisfied as specified -> 400
	ErrForbidden = errors.New("forbidden")     // the action is refused by policy -> 403
)

Functions

func Conflictf

func Conflictf(format string, args ...any) error

func Forbiddenf

func Forbiddenf(format string, args ...any) error

func Invalidf

func Invalidf(format string, args ...any) error

func NotFoundf

func NotFoundf(format string, args ...any) error

NotFoundf, Conflictf, Invalidf and Forbiddenf format an error exactly like fmt.Errorf (including %w wrapping) and tag it with the corresponding marker. The tag survives further fmt.Errorf("...: %w", err) wrapping.

Types

This section is empty.

Jump to

Keyboard shortcuts

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