oops

package
v0.0.0-...-1cb9f0d Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package oops is dev-idp's lightweight error helper. It mirrors enough of the surface from server/internal/oops for the service code to compile, minus the OTel hooks. Errors carry a Code (mapped to HTTP status) and a public message; .Log() emits via slog.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string
const (
	CodeBadRequest         Code = "bad_request"
	CodeNotFound           Code = "not_found"
	CodeConflict           Code = "conflict"
	CodeUnauthorized       Code = "unauthorized"
	CodeForbidden          Code = "forbidden"
	CodeInvalid            Code = "invalid"
	CodeUnexpected         Code = "unexpected"
	CodeGatewayError       Code = "gateway_error"
	CodeInvariantViolation Code = "invariant_violation"
	CodeNotImplemented     Code = "not_implemented"
)

type ShareableError

type ShareableError struct {
	Code Code
	// contains filtered or unexported fields
}

ShareableError carries a public-facing message plus the cause. The cause is wrapped in the .Error() output so dev-idp's permissive error encoder can leak it to the browser.

func E

func E(code Code, cause error, public string, args ...any) *ShareableError

func (*ShareableError) AsGoa

func (e *ShareableError) AsGoa() *goa.ServiceError

AsGoa converts to a goa.ServiceError using the code as the name. The .Error() output (public + cause) becomes the response message body.

func (*ShareableError) Error

func (e *ShareableError) Error() string

func (*ShareableError) HTTPStatus

func (e *ShareableError) HTTPStatus() int

func (*ShareableError) Log

func (e *ShareableError) Log(ctx context.Context, logger *slog.Logger, args ...slog.Attr) *ShareableError

Log emits a slog Error and returns the receiver for chaining.

func (*ShareableError) Unwrap

func (e *ShareableError) Unwrap() error

Jump to

Keyboard shortcuts

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