errors

package
v2.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: Apache-2.0 Imports: 5 Imported by: 276

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 BadRequest

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

BadRequest generates a 400 error.

func Conflict

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

Conflict generates a 409 error.

func Equal added in v2.3.0

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 InternalServerError

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

InternalServerError generates a 500 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 Timeout

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

Timeout generates a 408 error.

func Unauthorized

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

Unauthorized generates a 401 error.

Types

type Error

type Error struct {
	Id                   string   `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Code                 int32    `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
	Detail               string   `protobuf:"bytes,3,opt,name=detail,proto3" json:"detail,omitempty"`
	Status               string   `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func FromError added in v2.4.0

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) Descriptor added in v2.1.0

func (*Error) Descriptor() ([]byte, []int)

func (*Error) Error

func (e *Error) Error() string

func (*Error) GetCode added in v2.1.0

func (m *Error) GetCode() int32

func (*Error) GetDetail added in v2.1.0

func (m *Error) GetDetail() string

func (*Error) GetId added in v2.1.0

func (m *Error) GetId() string

func (*Error) GetStatus added in v2.1.0

func (m *Error) GetStatus() string

func (*Error) ProtoMessage added in v2.1.0

func (*Error) ProtoMessage()

func (*Error) Reset added in v2.1.0

func (m *Error) Reset()

func (*Error) String added in v2.1.0

func (m *Error) String() string

func (*Error) XXX_DiscardUnknown added in v2.1.0

func (m *Error) XXX_DiscardUnknown()

func (*Error) XXX_Marshal added in v2.1.0

func (m *Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Error) XXX_Merge added in v2.1.0

func (m *Error) XXX_Merge(src proto.Message)

func (*Error) XXX_Size added in v2.1.0

func (m *Error) XXX_Size() int

func (*Error) XXX_Unmarshal added in v2.1.0

func (m *Error) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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