package errors

import "github.com/influxdata/influxdb/kit/errors"

Index

Constants

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
)

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.

Source Files

errors.go list.go

Version
v1.12.0 (latest)
Published
Apr 8, 2025
Platform
linux/amd64
Imports
4 packages
Last checked
2 days ago

Tools for package owners.