errors

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	UnknownCode    = -1
	UnknownReason  = "UnknownError"
	UnknownMessage = "unknown error"
	DefaultStatus  = http.StatusInternalServerError
)

Variables

View Source
var (
	// optional int32 code = 1109;
	E_Code = &file_third_party_errors_errors_proto_extTypes[1]
	// optional string desc = 1110;
	E_Desc = &file_third_party_errors_errors_proto_extTypes[2]
)

Extension fields to descriptorpb.EnumValueOptions.

View Source
var (
	// optional int32 default_code = 1108;
	E_DefaultCode = &file_third_party_errors_errors_proto_extTypes[0]
)

Extension fields to descriptorpb.EnumOptions.

View Source
var File_third_party_errors_errors_proto protoreflect.FileDescriptor

Functions

func IsError

func IsError(err error) bool

Types

type Error

type Error interface {
	error
	Code() int32
	HttpStatus() int32
	Reason() string
	Message() string
	Metadata() map[string]string
	Unwrap() error
}

func BadRequest

func BadRequest(code int32, reason, message string) Error

func BadRequestCause

func BadRequestCause(code int32, reason, message string, err error) Error

func Forbidden

func Forbidden(code int32, reason, message string) Error

func ForbiddenCause

func ForbiddenCause(code int32, reason, message string, err error) Error

func FromError

func FromError(code, status int32, reason, message string, err error) Error

func FromErrorf

func FromErrorf(code, status int32, reason string, err error, format string, args ...interface{}) Error

func InternalServer

func InternalServer(code int32, reason, message string) Error

func InternalServerCause

func InternalServerCause(code int32, reason, message string, err error) Error

func New

func New(code, status int32, reason, message string) Error

func Newf

func Newf(code, status int32, reason, format string, args ...interface{}) Error

func NotFound

func NotFound(code int32, reason, message string) Error

func NotFoundCause

func NotFoundCause(code int32, reason, message string, err error) Error

func ServiceUnavailable

func ServiceUnavailable(code int32, reason, message string) Error

func ServiceUnavailableCause

func ServiceUnavailableCause(code int32, reason, message string, err error) Error

func Unauthorized

func Unauthorized(code int32, reason, message string) Error

func UnauthorizedCause

func UnauthorizedCause(code int32, reason, message string, err error) Error

type ErrorImpl

type ErrorImpl struct {
	Code_     int32             `json:"code"`
	Reason_   string            `json:"reason"`
	Message_  string            `json:"message"`
	Metadata_ map[string]string `json:"metadata"`
	// contains filtered or unexported fields
}

func (*ErrorImpl) Code

func (e *ErrorImpl) Code() int32

func (*ErrorImpl) Error

func (e *ErrorImpl) Error() string

func (*ErrorImpl) HttpStatus

func (e *ErrorImpl) HttpStatus() int32

func (*ErrorImpl) Message

func (e *ErrorImpl) Message() string

func (*ErrorImpl) Metadata

func (e *ErrorImpl) Metadata() map[string]string

func (*ErrorImpl) Reason

func (e *ErrorImpl) Reason() string

func (*ErrorImpl) Unwrap

func (e *ErrorImpl) Unwrap() error

Jump to

Keyboard shortcuts

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