errors

package
v0.0.0-...-e5f8ed5 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: Apache-2.0 Imports: 4 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// Unknown error type is used for all generic errors
	Unknown = ErrorType(iota)
	// BadInput is used when any function encounters bad/incomplete input
	BadInput
	// NotFound is used when a resource cannot be located
	NotFound
)

Variables

This section is empty.

Functions

func GetGRPCErrorCode

func GetGRPCErrorCode(err error) codes.Code

GetGRPCErrorCode maps the ErrorType to gRPC status codes and returns it

func GetHTTPErrorCode

func GetHTTPErrorCode(err error) int

GetHTTPErrorCode maps the ErrorType to http status codes and returns it

func Newf

func Newf(et ErrorType, msg string, args ...interface{}) error

Newf creates a new errorData of the specified type with formatted message

func Wrapf

func Wrapf(err error, msg string, args ...interface{}) error

Wrapf creates a new wrapped errorData with formatted message

Types

type ErrorType

type ErrorType uint

ErrorType captures some common error types

func GetType

func GetType(err error) ErrorType

GetType returns the error type

type HTTPError

type HTTPError struct {
	Code    int
	Message string
}

HTTPError associates an error message with a HTTP status code.

func NewHTTPError

func NewHTTPError(err error) *HTTPError

NewHTTPError wraps generic Go error to a HTTPError type and returns it

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error satisfies the error interface

Jump to

Keyboard shortcuts

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