errors

package
v0.2.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeInvalidInput = typ{"invalid-input", 2, ""}
	TypeNotFound     = typ{"not-found", 3, ""}
	TypeUnsupported  = typ{"unsupported", 4, "Please check the documentation for supported features or raise an issue at https://github.com/signoz/foundry/issues for feature requests."}
	TypeInternal     = typ{"internal", 5, ""}
	TypeFatal        = typ{"fatal", 6, "Please raise an issue at https://github.com/signoz/foundry/issues with the error message and stacktrace."}
)

Exit codes use a compact 1-6 scheme rather than BSD sysexits.h. sysexits would force TypeInternal and TypeFatal to share EX_SOFTWARE (70), and the distinction matters: TypeFatal marks a recovered panic that should page, TypeInternal marks an expected-but-failed path. The custom scheme keeps those orthogonal and stays easy to remember in shell scripts.

The action string is the remediation hint surfaced to users (via the slog "exception" payload and the --format=json error envelope). Co-locating it with the type means adding a new error class is a one-place change.

Functions

func ExitCode added in v0.2.4

func ExitCode(err error) int

func LogAttr

func LogAttr(err error) slog.Attr

func Newf added in v0.2.1

func Newf(t typ, info string, args ...any) *base

func Wrapf added in v0.2.1

func Wrapf(cause error, t typ, format string, args ...any) error

Types

type Envelope added in v0.2.4

type Envelope struct {
	Exception *Exception
}

func EnvelopeOf added in v0.2.4

func EnvelopeOf(err error) Envelope

func (Envelope) MarshalJSON added in v0.2.4

func (e Envelope) MarshalJSON() ([]byte, error)

type Exception added in v0.2.4

type Exception struct {
	Type       string     `json:"type,omitempty"`
	Message    string     `json:"message"`
	Cause      *Exception `json:"cause,omitempty"`
	Action     string     `json:"action,omitempty"`
	Stacktrace string     `json:"stacktrace,omitempty"`
}

func ExceptionOf added in v0.2.4

func ExceptionOf(err error) *Exception

The walk terminates at the first non-*base link, which emits Message alone — stdlib wrappers format their full subtree in Error(), so re-walking them would duplicate that text. Stacktrace emits on TypeFatal links only; every *base captures one at construction time but emitting them all is noise.

Jump to

Keyboard shortcuts

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