errors

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package errors provides an interface for all errors returned from Tharsis.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorMessage

func ErrorMessage(err error) string

ErrorMessage returns the messages associated with the error

func IsContextCanceledError added in v0.14.0

func IsContextCanceledError(err error) bool

IsContextCanceledError returns true if the error is a context.Canceled error

Types

type CodeType added in v0.15.0

type CodeType string

CodeType is used to specify the type of error

const (
	EInternal           CodeType = "internal error"
	ENotImplemented     CodeType = "not implemented"
	ENotFound           CodeType = "not found"
	EConflict           CodeType = "conflict"
	EOptimisticLock     CodeType = "optimistic lock"
	EInvalid            CodeType = "invalid"
	EForbidden          CodeType = "forbidden"
	ETooManyRequests    CodeType = "too many requests"
	EUnauthorized       CodeType = "unauthorized"
	ETooLarge           CodeType = "request too large"
	EServiceUnavailable CodeType = "service unavailable"
)

Error code constants

func ErrorCode

func ErrorCode(err error) CodeType

ErrorCode returns the code of the root error, if available; otherwise returns EINTERNAL.

type Option added in v0.15.0

type Option func(*config)

Option is is used to configure a TharsisError.

func WithErrorCode added in v0.15.0

func WithErrorCode(code CodeType) Option

WithErrorCode sets the error code on the TharsisError.

func WithSpan added in v0.15.0

func WithSpan(span trace.Span) Option

WithSpan records the error on the span and sets the status to Error.

type TharsisError

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

TharsisError is the internal error implementation for the Tharsis API

func New

func New(format string, a ...any) *TharsisError

New returns a new Tharsis error with the code and message fields set

func Wrap

func Wrap(err error, format string, a ...any) *TharsisError

Wrap returns a new TharsisError which wraps an existing error

func (*TharsisError) Error

func (e *TharsisError) Error() string

Error implements the error interface by writing out the recursive messages.

func (*TharsisError) Unwrap added in v0.15.1

func (e *TharsisError) Unwrap() error

Unwrap returns the wrapped error, if any.

Jump to

Keyboard shortcuts

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