errors

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasTag

func HasTag(err error, tag string) bool

HasTag returns true if err has the provided tag

If not an Error, returns false

func IsError

func IsError(err error) bool

IsError returns true if the provided error interface is an Error

func Root

func Root(err error) string

Root returns the root message of an Error

If not an Error, returns err.Error()

func RootContext

func RootContext(err error) string

RootContext returns the root context of an Error

If not an Error, returns err.Error()

func RootContextErr

func RootContextErr(err error) error

RootContextErr returns the root context of an Error as an error

If not an Error, returns err

func RootErr

func RootErr(err error) error

RootErr returns the root message of an Error as an error

If not an Error, returns err

func Status

func Status(err error) string

Status returns the status

If not an Error, returns ""

func Tags

func Tags(err error) []string

Tags returns the tags an Error

If not an Error, returns an empty list

func Trace

func Trace(err error) string

Trace returns the trace messages of an Error

If not an Error, returns err.Error()

func TraceContext

func TraceContext(err error) string

TraceContext returns the trace context of an Error

If not an Error, returns err.Error()

func TraceContextErr

func TraceContextErr(err error) error

TraceContextErr returns the trace context of an Error as an error

If not an Error, returns err

func TraceErr

func TraceErr(err error) error

TraceErr returns the trace messages of an Error as an error

If not an Error, returns err

Types

type Error

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

Error represents an error entity

func AddTag

func AddTag(err error, tag string) *Error

AddTag adds the provided tag to err and returns the result

If not an Error, returns a new Error with the tag

func AsError

func AsError(err error) *Error

AsError returns the provided error interface as an Error

Returns nil if the provided error is not an Error

func ErrorAction

func ErrorAction(action logutils.MessageActionType, dataType logutils.MessageDataType, args logutils.MessageArgs) *Error

ErrorAction generates an error for an action

action: The action that is occurring
dataType: The data type that the action is occurring on
args: Any args that should be included in the message (nil if none)

func ErrorData

func ErrorData(status logutils.MessageDataStatus, dataType logutils.MessageDataType, args logutils.MessageArgs) *Error

ErrorData generates an error for a data element

status: The status of the data
dataType: The data type that the error is occurring on
args: Any args that should be included in the message (nil if none)

func New

func New(message string) *Error

New returns an Error containing the provided message

func Newf

func Newf(message string, args ...interface{}) *Error

Newf returns an Error containing the formatted message

func SetStatus

func SetStatus(err error, status string) *Error

SetStatus sets the status and returns the result

If not an Error, returns a new Error with the status

func Wrap

func Wrap(message string, err error) *Error

Wrap returns an Error containing the provided message and error

func WrapErrorAction

func WrapErrorAction(action logutils.MessageActionType, dataType logutils.MessageDataType, args logutils.MessageArgs, err error) *Error

WrapErrorAction wraps an error for an action

action: The action that is occurring
dataType: The data type that the action is occurring on
args: Any args that should be included in the message (nil if none)
err: Error to wrap

func WrapErrorData

func WrapErrorData(status logutils.MessageDataStatus, dataType logutils.MessageDataType, args logutils.MessageArgs, err error) *Error

WrapErrorData wraps an error for a data element

	status: The status of the data
	dataType: The data type that the error is occurring on
	args: Any args that should be included in the message (nil if none)
 err: Error to wrap

func Wrapf

func Wrapf(format string, err error, args ...interface{}) *Error

Wrapf returns an Error containing the formatted message and provided error

func (Error) AddTag

func (e Error) AddTag(tag string) *Error

AddTag adds the provided tag and returns the result

func (*Error) Error

func (e *Error) Error() string

Error returns the full trace context as an error

func (*Error) HasTag

func (e *Error) HasTag(tag string) bool

HasTag returns true if the Error has the provided tag

func (*Error) Internal added in v2.2.0

func (e *Error) Internal() error

Internal returns the internal error

func (*Error) Root

func (e *Error) Root() string

Root returns the root message

func (*Error) RootContext

func (e *Error) RootContext() string

RootContext returns the root context

func (*Error) RootContextErr

func (e *Error) RootContextErr() error

RootContextErr returns the root context as an error

func (*Error) RootErr

func (e *Error) RootErr() error

RootErr returns the root message as an error

func (Error) SetStatus

func (e Error) SetStatus(status string) *Error

SetStatus sets the status and returns the result

func (*Error) Status

func (e *Error) Status() string

Status returns the status

func (*Error) String

func (e *Error) String() string

String returns the root message as a string

func (*Error) Tags

func (e *Error) Tags() []string

Tags returns the tags

func (*Error) Trace

func (e *Error) Trace() string

Trace returns the trace messages

func (*Error) TraceContext

func (e *Error) TraceContext() string

TraceContext returns the trace context

func (*Error) TraceContextErr

func (e *Error) TraceContextErr() error

TraceContextErr returns the trace context as an error

func (*Error) TraceErr

func (e *Error) TraceErr() error

TraceErr returns the trace messages as an error

type ErrorContext

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

ErrorContext represents the context of an error message

func (ErrorContext) String

func (e ErrorContext) String() string

String converts the ErrorContext to a string

Jump to

Keyboard shortcuts

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