apperr

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package apperr defines transport-neutral application errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeOf

func CodeOf(err error) int

CodeOf extracts the stable application code.

func GRPCStatus

func GRPCStatus(err error) error

GRPCStatus maps an application error to a gRPC status error without exposing its internal cause.

func HTTPStatus

func HTTPStatus(err error) int

HTTPStatus maps an application error code to an HTTP status.

func PublicMessage

func PublicMessage(err error) string

PublicMessage returns a safe client-facing message.

func Retryable

func Retryable(err error) bool

Retryable reports whether an error was explicitly marked retryable.

Types

type Error

type Error struct {
	Code      int
	Message   string
	Cause     error
	Retryable bool
}

Error contains a stable public code/message and an optional internal cause. Message is intended for clients; details from Cause must only be logged.

func New

func New(code int, message string) *Error

New creates a public application error.

func Wrap

func Wrap(code int, message string, cause error) *Error

Wrap creates an application error while retaining an internal cause.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

func (*Error) WithRetryable

func (e *Error) WithRetryable(retryable bool) *Error

WithRetryable marks an error as safe for a retry policy.

Jump to

Keyboard shortcuts

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