erring

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrPrefix

type ErrPrefix string

ErrPrefix is a string that can be used to prefix an error message.

func (ErrPrefix) ErrorIf

func (p ErrPrefix) ErrorIf(err error) error

ErrorIf returns a error with prefix if the error is not nil, otherwise it returns nil.

func (ErrPrefix) ErrorMap

func (p ErrPrefix) ErrorMap(data []byte, err error) ([]byte, error)

ErrorMap is used to unwrap result from a function that returns a byte slice and an error. If the error is not nil, it returns the error with prefix, otherwise it returns the byte slice.

func (ErrPrefix) Errorf

func (p ErrPrefix) Errorf(format string, a ...any) error

Errorf returns a error with prefix and given format and arguments.

func (ErrPrefix) Sprintf added in v0.0.4

func (p ErrPrefix) Sprintf(format string, a ...any) string

Sprintf returns a string with prefix and given format and arguments.

type Error added in v0.1.0

type Error struct {
	Code    int    `json:"code" cbor:"code"`
	Message string `json:"message" cbor:"message"`
	Data    any    `json:"data,omitempty" cbor:"data,omitempty"`
	// contains filtered or unexported fields
}

Error represents a error with more information, can be used as response error.

func (*Error) As added in v0.1.0

func (e *Error) As(target any) bool

As implements the errors.As interface.

func (*Error) CatchIf added in v0.1.0

func (e *Error) CatchIf(err error) bool

CatchIf catches the error and return true if the error is not nil.

func (*Error) Error added in v0.1.0

func (e *Error) Error() string

Error returns the full error information as a JSON string, used as error log.

func (*Error) HasErrs added in v0.1.0

func (e *Error) HasErrs() bool

HasErrs return true if the Error has underlying errors.

func (*Error) Is added in v0.1.0

func (e *Error) Is(target error) bool

Is implements the errors.As interface.

func (*Error) Unwrap added in v0.1.0

func (e *Error) Unwrap() []error

Unwrap implements the errors.Unwrap interface.

type RespondError added in v0.1.0

type RespondError struct {
	Err any `json:"error" cbor:"error"`
}

RespondError represents a response with error that can be sent to the client.

Jump to

Keyboard shortcuts

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