errors

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

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

View Source
var File_errors_proto protoreflect.FileDescriptor

File_errors_proto ...

Functions

func Equal

func Equal(err1 error, err2 error) bool

Equal tries to compare errors

func New

func New(id, msg string, code ErrorCoder) error

New generates a custom error.

Types

type Error

type Error struct {
	RequestId string `protobuf:"bytes,1,opt,name=requestId,proto3" json:"requestId,omitempty"`
	Code      int32  `protobuf:"varint,2,opt,name=code,proto3" json:"code,omitempty"`
	Msg       string `protobuf:"bytes,3,opt,name=msg,proto3" json:"msg,omitempty"`
	Status    string `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

Error ...

func FromError

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 deprecated

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

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Error

func (e *Error) Error() string

Error go:generate protoc -I. --go_out=paths=source_relative:. errors.proto

func (*Error) GetCode

func (x *Error) GetCode() int32

GetCode ...

func (*Error) GetMsg

func (x *Error) GetMsg() string

GetMsg ...

func (*Error) GetRequestId

func (x *Error) GetRequestId() string

GetRequestId ...

func (*Error) GetStatus

func (x *Error) GetStatus() string

GetStatus ...

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

ProtoMessage ...

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

ProtoReflect ...

func (*Error) Reset

func (x *Error) Reset()

Reset ...

func (*Error) String

func (x *Error) String() string

String ...

type ErrorCode

type ErrorCode int32

ErrorCode ...

func (ErrorCode) Code

func (e ErrorCode) Code() int32

Code ...

func (ErrorCode) String

func (i ErrorCode) String() string

String ...

type ErrorCoder

type ErrorCoder interface {
	String() string
	Code() int32
}

ErrorCoder error code

Jump to

Keyboard shortcuts

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