errors

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package errors holds the typed Code system used across Parsec. Every coded error is convertible to a Twirp error and to a CLI exit reason.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Code

type Code string

Code is the typed error code. Values are DOMAIN_CATEGORY strings.

const (
	// Channel codes.
	ChannelInvalid    Code = "PARSEC_CHANNEL_INVALID"
	ChannelNotFound   Code = "PARSEC_CHANNEL_NOT_FOUND"
	ChannelExists     Code = "PARSEC_CHANNEL_EXISTS"
	ChannelClosed     Code = "PARSEC_CHANNEL_CLOSED"
	ChannelTTLExceeds Code = "PARSEC_CHANNEL_TTL_EXCEEDS_MAX"

	// Auth codes.
	AuthDenied  Code = "PARSEC_AUTH_DENIED"
	AuthExpired Code = "PARSEC_AUTH_EXPIRED"

	// Broker codes.
	BrokerNotReady Code = "PARSEC_BROKER_NOT_READY"
	BrokerInternal Code = "PARSEC_BROKER_INTERNAL"

	// Sink codes.
	SinkUnavailable Code = "PARSEC_SINK_UNAVAILABLE"
	SinkConfig      Code = "PARSEC_SINK_CONFIG_INVALID"
	SinkDLQOverflow Code = "PARSEC_SINK_DLQ_OVERFLOW"
	SinkDLQNotFound Code = "PARSEC_SINK_DLQ_NOT_FOUND"

	// Rate limit codes.
	RateLimited Code = "PARSEC_RATE_LIMITED"

	// Generic.
	InvalidArgument Code = "PARSEC_INVALID_ARGUMENT"
	Internal        Code = "PARSEC_INTERNAL"
)

func CodeOf

func CodeOf(err error) Code

CodeOf extracts the Code from err, or InternalCode if err is not a *Error. Useful at RPC boundaries.

type Error

type Error struct {
	Code  Code
	Msg   string
	Cause error
}

Error is a coded error. The Cause is preserved for log/debug but not exposed across the RPC boundary.

func New

func New(code Code, msg string) *Error

New constructs a coded error with no cause.

func Wrap

func Wrap(code Code, msg string, cause error) *Error

Wrap constructs a coded error that wraps a lower-level cause.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap exposes the underlying cause for errors.Is / errors.As.

Jump to

Keyboard shortcuts

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