errors

package
v3.8.2 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package errors provides a way to return detailed information for an RPC request error. The error is normally JSON encoded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadGateway

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

BadGateway generates a 502 error

func BadRequest

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

BadRequest generates a 400 error.

func Conflict

func Conflict(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(format string, a ...interface{}) error

Forbidden generates a 403 error.

func GatewayTimeout

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

GatewayTimeout generates a 504 error

func InternalServerError

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

InternalServerError generates a 500 error.

func MethodNotAllowed

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

MethodNotAllowed generates a 405 error.

func New

func New(detail string, code int32) error

New generates a custom error.

func NotFound

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

NotFound generates a 404 error.

func NotImplemented

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

NotImplemented generates a 501 error

func ServiceUnavailable

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

ServiceUnavailable generates a 503 error

func Timeout

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

Timeout generates a 408 error.

func Unauthorized

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

Unauthorized generates a 401 error.

Types

type Error

type Error struct {
	RequestId string `json:"request_id,omitempty"`
	Code      int32  `json:"code,omitempty"`
	Detail    string `json:"detail,omitempty"`
	Status    string `json:"status,omitempty"`
}

func FromError

func FromError(err error) *Error

FromError try to convert go error to *Error

func Parse

func Parse(err string, id ...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