errors

package
v4.3.1-alpha1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadGateway

func BadGateway(id, format string, a ...interface{}) error

BadGateway generates a 502 error

func BadRequest

func BadRequest(id, format string, a ...interface{}) error

BadRequest generates a 400 error.

func CodeFromHTTPStatus added in v4.0.7

func CodeFromHTTPStatus(status int) codes.Code

CodeFromHTTPStatus converts an HTTP response status into the corresponding gRPC error code.

func Conflict

func Conflict(id, format string, a ...interface{}) error

Conflict generates a 409 error.

func Equal

func Equal(err1 error, err2 error) bool

Equal tries to compare errors

func Forbidden

func Forbidden(id, format string, a ...interface{}) error

Forbidden generates a 403 error.

func FromGRPC added in v4.0.7

func FromGRPC(er error) error

func GatewayTimeout

func GatewayTimeout(id, format string, a ...interface{}) error

GatewayTimeout generates a 504 error

func InternalServerError

func InternalServerError(id, format string, a ...interface{}) error

InternalServerError generates a 500 error.

func IsContextCanceled

func IsContextCanceled(err error) bool

IsContextCanceled interprets error as a "context canceled"

func IsNetworkError

func IsNetworkError(err error) bool

IsNetworkError tries to detect if error is a network error.

func MethodNotAllowed

func MethodNotAllowed(id, format string, a ...interface{}) error

MethodNotAllowed generates a 405 error.

func New

func New(id, detail string, code int32) error

New generates a custom error.

func NotFound

func NotFound(id, format string, a ...interface{}) error

NotFound generates a 404 error.

func NotImplemented

func NotImplemented(id, format string, a ...interface{}) error

NotImplemented generates a 501 error

func ServiceUnavailable

func ServiceUnavailable(id, format string, a ...interface{}) error

ServiceUnavailable generates a 503 error

func Timeout

func Timeout(id, format string, a ...interface{}) error

Timeout generates a 408 error.

func ToGRPC added in v4.0.7

func ToGRPC(er error) error

func Unauthorized

func Unauthorized(id, format string, a ...interface{}) error

Unauthorized generates a 401 error.

Types

type Error

type Error struct {
	Id     string
	Code   int32
	Detail string
	Status string
}

func FromError

func FromError(err error) *Error

FromError try to convert go error to *Error

func Parse

func Parse(err string) *Error

Parse tries to parse a JSON string into an error. If that fails, it will set the given string as the error detail.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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