Help us shape the future of Go! Take the 2026 Go Developer Survey

errors2

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// InternalError indicates an unexpected error condition.
	InternalError = 1
	// MalformedData indicates malformed input, such as unparsable JSON.
	MalformedData = 2
	// InvalidData indicates that data is well-formed, but invalid.
	InvalidData = 3
	// Forbidden indicates a forbidden operation.
	Forbidden = 4
	// NotFound indicates a resource was not found.
	NotFound = 5
)

Variables

This section is empty.

Functions

func BadRequestError

func BadRequestError(msg string) error

func Errorf

func Errorf(ref int, format string, i ...interface{}) error

Errorf constructs an Error with the given reference code and format.

func Forbiddenf

func Forbiddenf(format string, i ...interface{}) error

Forbiddenf constructs a Forbidden error with the given format.

func InternalErrorf

func InternalErrorf(format string, i ...interface{}) error

InternalErrorf constructs an InternalError with the given format.

func InvalidDataf

func InvalidDataf(format string, i ...interface{}) error

InvalidDataf constructs an InvalidData error with the given format.

func MalformedDataf

func MalformedDataf(format string, i ...interface{}) error

MalformedDataf constructs a MalformedData error with the given format.

func New

func New(msg string, ref ...int) error

New creates a new error with a message and error code.

func Wrap

func Wrap(err error, msg string, ref ...int) error

Types

type Error

type Error struct {
	Reference int    `json:"referenceCode"`
	Code      int    `json:"statusCode"`
	Err       string `json:"err"`
}

Error indicates an error with a reference code and an HTTP status code.

func (Error) Error

func (e Error) Error() string

Error implements the error interface.

type List

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

List represents a list of errors.

func (*List) Append

func (l *List) Append(err error)

Append adds err to the errors list.

func (*List) AppendString

func (l *List) AppendString(text string)

AppendString adds a new error that formats as the given text.

func (*List) Clear

func (l *List) Clear()

Clear removes all the previously appended errors from the list.

func (*List) Err

func (l *List) Err() error

Err returns an error composed of the list of errors, separated by a new line, or nil if no errors were appended.

Jump to

Keyboard shortcuts

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