errors

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package errors defines transport-neutral Keelith application errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is an immutable transport-neutral application error.

Code and Reason form its stable machine identity. Message is human-facing and may vary without changing errors.Is matching.

func FromFrame

func FromFrame(frame Frame) *Error

FromFrame creates an Error without a private Cause.

func New

func New(code int32, reason, message string, options ...Option) *Error

New constructs an Error without a Cause.

func Wrap

func Wrap(cause error, code int32, reason, message string, options ...Option) *Error

Wrap constructs an Error that unwraps to cause.

func (*Error) Clone

func (e *Error) Clone(options ...Option) *Error

Clone returns an independent immutable copy with options applied.

func (*Error) Code

func (e *Error) Code() int32

Code returns the stable numeric application code.

func (*Error) Error

func (e *Error) Error() string

Error returns a human-readable description without exposing the Cause.

func (*Error) Is

func (e *Error) Is(candidate error) bool

Is matches another Error by stable Code and Reason.

func (*Error) Message

func (e *Error) Message() string

Message returns the human-facing message.

func (*Error) Metadata

func (e *Error) Metadata() map[string]string

Metadata returns a defensive copy of error metadata.

func (*Error) Reason

func (e *Error) Reason() string

Reason returns the stable machine-readable reason.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the private implementation Cause.

type Frame

type Frame struct {
	Code     int32
	Reason   string
	Message  string
	Metadata map[string]string
}

Frame is the transport-neutral, serializable projection of an Error.

Cause is deliberately absent because implementation errors must not cross a transport boundary.

func ToFrame

func ToFrame(target *Error) Frame

ToFrame creates an independent wire projection of target.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures a new Error or an immutable Clone.

func WithMessage

func WithMessage(message string) Option

WithMessage replaces the human-facing message.

func WithMetadata

func WithMetadata(metadata map[string]string) Option

WithMetadata merges a defensive copy of metadata into the Error.

Jump to

Keyboard shortcuts

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