errors

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: MIT Imports: 9 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     StatusCode `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 ClientException added in v1.4.1

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

ClientException generates a custom client exception.

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 StatusCode) *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 PreconditionFailed added in v1.3.0

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

PreconditionFailed generates a 412 error.

func ServerException added in v1.4.1

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

ServerException generates a custom server exception

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 TooManyRequests added in v1.3.0

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

TooManyRequests generates a 429 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 (e *Error) Reset()

func (*Error) String

func (e *Error) String() string

func (Error) ToGRPC added in v1.4.1

func (e Error) ToGRPC() *status.Status

func (*Error) WithChild

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

WithChild fills Error.Child

func (*Error) WithCode added in v1.3.0

func (e *Error) WithCode(code StatusCode) *Error

func (*Error) WithId added in v1.3.0

func (e *Error) WithId(id string) *Error

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

type StatusCode added in v1.4.1

type StatusCode int32
const (
	StatusBadRequest          StatusCode = 400
	StatusUnauthorized        StatusCode = 401
	StatusForbidden           StatusCode = 403
	StatusNotFound            StatusCode = 404
	StatusMethodNotAllowed    StatusCode = 405
	StatusTimeout             StatusCode = 408
	StatusConflict            StatusCode = 409
	StatusPreconditionFiled   StatusCode = 412
	StatusTooManyRequests     StatusCode = 429
	StatusClientException     StatusCode = 499
	StatusInternalServerError StatusCode = 500
	StatusNotImplemented      StatusCode = 501
	StatusBadGateway          StatusCode = 502
	StatusServiceUnavailable  StatusCode = 503
	StatusGatewayTimeout      StatusCode = 504
	StatusServerException     StatusCode = 599
)

func (StatusCode) String added in v1.4.1

func (c StatusCode) String() string

Jump to

Keyboard shortcuts

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