ierr

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultStatus = 200
)

Variables

View Source
var (
	UnknownStatus = 500
	UnknownCode   = 9999
)

Functions

func IsBadRequest

func IsBadRequest(err error) bool

func IsConflict

func IsConflict(err error) bool

func IsForbidden

func IsForbidden(err error) bool

func IsInternalServer

func IsInternalServer(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func Status

func Status(err error) int

Types

type Error

type Error struct {
	Code     int               `json:"code"`
	Message  string            `json:"message,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
	// contains filtered or unexported fields
}

func BadRequest

func BadRequest(code int, format string, args ...any) *Error

func Conflict

func Conflict(code int, format string, args ...any) *Error

func Forbidden

func Forbidden(code int, format string, args ...any) *Error

func FromError

func FromError(err error) *Error

func InternalServer

func InternalServer(code int, format string, args ...any) *Error

func New

func New(status, code int, format string, args ...any) *Error

func NotFound

func NotFound(code int, format string, args ...any) *Error

func Unauthorized

func Unauthorized(code int, format string, args ...any) *Error

func (*Error) AppendMessage

func (e *Error) AppendMessage(format string, args ...any) *Error

func (*Error) AppendMetadata

func (e *Error) AppendMetadata(metadata map[string]string) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) GRPCStatus

func (e *Error) GRPCStatus() *status.Status

func (*Error) Status

func (e *Error) Status() int

func (*Error) String

func (e *Error) String() string

func (*Error) WithMetadata

func (e *Error) WithMetadata(metadata map[string]string) *Error

Jump to

Keyboard shortcuts

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