errors

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2021 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(err1 error, err2 error) bool

Equal tries to compare errors

Types

type Child

type Child struct {
	Code   int32  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Detail string `protobuf:"bytes,2,opt,name=detail,proto3" json:"detail,omitempty"`
}

func (*Child) ProtoMessage

func (*Child) ProtoMessage()

func (*Child) Reset

func (m *Child) Reset()

func (*Child) String

func (m *Child) String() string

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"`
	Position string   `protobuf:"bytes,5,opt,name=position,proto3" json:"position,omitempty"`
	Child    *Child   `protobuf:"bytes,6,opt,name=child,proto3" json:"child,omitempty"`
	Stacks   []*Stack `protobuf:"bytes,7,rep,name=stacks,proto3" json:"stacks,omitempty"`
}

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 Conflict

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

Conflict generates a 409 error.

func Forbidden

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

Forbidden generates a 403 error.

func FromErr

func FromErr(err error) *Error

FromErr try to convert go error go *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 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 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 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 Unauthorized

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

Unauthorized generates a 401 error.

func (*Error) Error

func (e *Error) Error() string

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) Reset

func (m *Error) Reset()

func (*Error) String

func (m *Error) String() string

func (*Error) WithChild

func (e *Error) WithChild(code int32, format string, a ...interface{}) *Error

WithChild fills Error.Child

func (*Error) WithPos

func (e *Error) WithPos() *Error

WithPos fills Error.Position

func (*Error) WithStack

func (e *Error) WithStack(code int32, detail string, pos ...bool) *Error

WithStack push stack information to Error

type Stack

type Stack struct {
	Code     int32  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
	Detail   string `protobuf:"bytes,2,opt,name=detail,proto3" json:"detail,omitempty"`
	Position string `protobuf:"bytes,3,opt,name=position,proto3" json:"position,omitempty"`
}

func (*Stack) ProtoMessage

func (*Stack) ProtoMessage()

func (*Stack) Reset

func (m *Stack) Reset()

func (*Stack) String

func (m *Stack) String() string

Jump to

Keyboard shortcuts

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