errors

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2025 License: Apache-2.0 Imports: 2 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is

func Is(err error, target error) bool

func IsAlreadyExists

func IsAlreadyExists(err error) bool

IsAlreadyExists returns true if err item already exists in the space

func IsForbidden

func IsForbidden(err error) bool

IsForbidden returns true if err is due to Forbidden action

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument returns true if err item is invalid argument

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if err item isn't found in the space

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns true if err is due to Unauthorized request

func New

func New(msg string) error

Creates a new error msg without error code

func Wrap

func Wrap(code ErrCode, msg string) error

Wraps the error msg with recognized error codes

func Wrapf

func Wrapf(code ErrCode, format string, v ...any) error

Wraps the error msg with recognized error codes using specified message format

Types

type ErrCode

type ErrCode int

ErrCode is type for multiple reconizable errors.

const (
	// if error is unknown
	Unknown ErrCode = 0

	// if the item not found in the space
	NotFound ErrCode = 1

	// if the item already present in the space
	AlreadyExists ErrCode = 2

	// if the argument is not valid
	InvalidArgument ErrCode = 3

	// Unauthorized request error
	Unauthorized ErrCode = 4

	// Forbidden action error
	Forbidden ErrCode = 5
)

error codes

func GetErrCode

func GetErrCode(err error) ErrCode

get the error code if the error is associated to recognizable error types

type Error

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

base error structure

func (Error) Error

func (e Error) Error() string

Error() prints out the error message string

Jump to

Keyboard shortcuts

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