apierrors

package
v0.0.0-...-e82f8c1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	APIErrorDetail errorutil.DetailTag = "api"
	TenantDetail   errorutil.DetailTag = "tenant"
)

Variables

View Source
var SkipLoggingForKinds map[Kind]bool
View Source
var ValidationFailed = Invalid.WithReason("ValidationFailed")

Functions

func AddDetails

func AddDetails(err error, d errorutil.Details) error

func IgnoreError

func IgnoreError(err error) (ignore bool)

func IsAPIError

func IsAPIError(err error) bool

func IsKind

func IsKind(err error, kind Kind) bool

func NewBadRequest

func NewBadRequest(msg string) error

func NewDataRace

func NewDataRace(msg string) error

func NewForbidden

func NewForbidden(msg string) error

func NewInternalError

func NewInternalError(msg string) error

func NewInvalid

func NewInvalid(msg string) error

func NewNotFound

func NewNotFound(msg string) error

func NewTooManyRequest

func NewTooManyRequest(msg string) error

func NewUnauthorized

func NewUnauthorized(msg string) error

Types

type APIError

type APIError struct {
	Kind
	Message string                 `json:"message"`
	Code    int                    `json:"code"`
	Info    map[string]interface{} `json:"info,omitempty"`
}

func AsAPIError

func AsAPIError(err error) *APIError

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) HasCause

func (e *APIError) HasCause(kind string) bool

type Cause

type Cause interface{ Kind() string }

type Details

type Details errorutil.Details

type Kind

type Kind struct {
	Name   Name   `json:"name"`
	Reason string `json:"reason"`
}

func (Kind) Errorf

func (k Kind) Errorf(format string, args ...interface{}) error

func (Kind) New

func (k Kind) New(msg string) error

func (Kind) NewWithCause

func (k Kind) NewWithCause(msg string, c Cause) error

func (Kind) NewWithCauses

func (k Kind) NewWithCauses(msg string, cs []Cause) error

func (Kind) NewWithDetails

func (k Kind) NewWithDetails(msg string, details Details) error

func (Kind) NewWithInfo

func (k Kind) NewWithInfo(msg string, info Details) error

func (Kind) Wrap

func (k Kind) Wrap(err error, msg string) error

type MapCause

type MapCause struct {
	CauseKind string
	Data      map[string]interface{}
}

func (MapCause) Kind

func (c MapCause) Kind() string

func (MapCause) MarshalJSON

func (c MapCause) MarshalJSON() ([]byte, error)

type Name

type Name string
const (
	BadRequest            Name = "BadRequest"
	Invalid               Name = "Invalid"
	Unauthorized          Name = "Unauthorized"
	Forbidden             Name = "Forbidden"
	NotFound              Name = "NotFound"
	AlreadyExists         Name = "AlreadyExists"
	DataRace              Name = "DataRace"
	TooManyRequest        Name = "TooManyRequest"
	InternalError         Name = "InternalError"
	ServiceUnavailable    Name = "ServiceUnavailable"
	RequestEntityTooLarge Name = "RequestEntityTooLarge"
)

func (Name) HTTPStatus

func (n Name) HTTPStatus() int

func (Name) WithReason

func (n Name) WithReason(reason string) Kind

type SkipLoggingHook

type SkipLoggingHook struct{}

func (SkipLoggingHook) Fire

func (SkipLoggingHook) Fire(entry *logrus.Entry) error

func (SkipLoggingHook) Levels

func (SkipLoggingHook) Levels() []logrus.Level

type StringCause

type StringCause string

func (StringCause) Kind

func (c StringCause) Kind() string

func (StringCause) MarshalJSON

func (c StringCause) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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