errors

package
v0.0.0-...-cbea63e Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2021 License: Apache-2.0 Imports: 7 Imported by: 36

Documentation

Index

Constants

View Source
const (
	ErrorInternalServer = "INTERNAL_SERVER_ERROR"
	ErrorBadRequest     = "BAD_REQUEST"
	ErrorForbidden      = "FORBIDDEN"
	ErrorBadResponse    = "BAD_RESPONSE"
	ErrorTimeout        = "TIMEOUT"
	ErrorNotFound       = "NOT_FOUND"
	ErrorConflict       = "CONFLICT"
	ErrorUnauthorized   = "UNAUTHORIZED"
	ErrorCircuitBroken  = "CIRCUIT_BROKEN"
)

Variables

This section is empty.

Functions

func Clear

func Clear(code string, context ...string)

Clear clears the counters for an error

func Cleared

func Cleared() time.Time

func Count

func Count(code string, context ...string) int

Count returns the count for an error

func Get

func Get(code string, context ...string) counters

Get returns a counter for an error

func IsBadRequest

func IsBadRequest(err error) bool

func IsBadResponse

func IsBadResponse(err error) bool

func IsCircuitBroken

func IsCircuitBroken(err error) bool

func IsConflict

func IsConflict(err error) bool

func IsForbidden

func IsForbidden(err error) bool

func IsInternalServerError

func IsInternalServerError(err error) bool

func IsNotFound

func IsNotFound(err error) bool

func IsTimeout

func IsTimeout(err error) bool

func IsUnauthorized

func IsUnauthorized(err error) bool

func ToProtobuf

func ToProtobuf(err Error) *pe.PlatformError

ToProtobuf takes a Error and returns a protobuf error

func Track

func Track(code string, context ...string)

Track increments the count for an error

Types

type Error

type Error interface {
	Error() string
	Type() string
	Code() string
	Description() string
	HttpCode() uint32
	Context() []string
	AddContext(...string) Error
	MultiStack() *stack.Multi
}

Error represents our customer error type

func BadRequest

func BadRequest(code string, errValue interface{}, context ...string) Error

BadRequest error message

func BadResponse

func BadResponse(code string, errValue interface{}, context ...string) Error

BadResponse error message

func CircuitBroken

func CircuitBroken(code string, errValue interface{}, context ...string) Error

func Conflict

func Conflict(code string, errValue interface{}, context ...string) Error

Conflict error message

func Forbidden

func Forbidden(code string, errValue interface{}, context ...string) Error

Forbidden error message

func FromProtobuf

func FromProtobuf(err *pe.PlatformError) Error

FromProtobuf takes a protobuf error and returns an Error as above

func InternalServerError

func InternalServerError(code string, errValue interface{}, context ...string) Error

InternalServerError message

func NotFound

func NotFound(code string, errValue interface{}, context ...string) Error

NotFound error message

func Timeout

func Timeout(code string, errValue interface{}, context ...string) Error

Timeout error message

func Unauthorized

func Unauthorized(code string, errValue interface{}, context ...string) Error

Unauthorized error code

type LocalError

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

LocalError is a type of error we build

func (LocalError) AddContext

func (self LocalError) AddContext(s ...string) Error

func (LocalError) Code

func (self LocalError) Code() string

Code returns the error code, e.g. com.hailocab.service.something.went.wrong

func (LocalError) Context

func (self LocalError) Context() []string

Context contains a list of strings with more information about the error

func (LocalError) Description

func (self LocalError) Description() string

Description returns a human readable version of the error

func (LocalError) Error

func (self LocalError) Error() string

Error representation is just the description

func (LocalError) HttpCode

func (self LocalError) HttpCode() uint32

HttpCode returns the HTTP code we should be returning back via the API

func (LocalError) MultiStack

func (self LocalError) MultiStack() *stack.Multi

MultiStack identifies the locations this error was wrapped at.

func (LocalError) Type

func (self LocalError) Type() string

Type returns the type of error message

Jump to

Keyboard shortcuts

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