errors

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: GPL-3.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package errors defines machine-readable AstraEngine errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCode

func IsCode(err error, code Code) bool

IsCode reports whether err has code.

func IsRetryable

func IsRetryable(err error) bool

IsRetryable reports whether a typed error can be retried.

func PublicMessage

func PublicMessage(err error) string

PublicMessage returns a safe client-facing message without the wrapped cause.

Types

type Code

type Code string

Code is a stable, machine-readable error category.

const (
	CodeInternal        Code = "internal"
	CodeInvalidArgument Code = "invalid_argument"
	CodeNotFound        Code = "not_found"
	CodeUnauthorized    Code = "unauthorized"
	CodeForbidden       Code = "forbidden"
	CodeConflict        Code = "conflict"
	CodeUnavailable     Code = "unavailable"
	CodeRateLimited     Code = "rate_limited"
	CodeUnsupported     Code = "unsupported"
	CodeCanceled        Code = "canceled"
	CodeDeadline        Code = "deadline_exceeded"
)

func CodeOf

func CodeOf(err error) Code

CodeOf returns the nearest AstraEngine code, including context cancellation.

type Error

type Error struct {
	Code      Code
	Op        string
	Message   string
	Platform  string
	Retryable bool
	Err       error
}

Error adds stable metadata to an underlying error.

func New

func New(code Code, message string) *Error

New creates an error with a safe public message.

func Wrap

func Wrap(err error, code Code, op string) *Error

Wrap annotates err with a code and operation while preserving its cause.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying cause for errors.Is and errors.As.

Jump to

Keyboard shortcuts

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