errors

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package errors provides a way to return detailed information for an RPC request error. The error is normally JSON encoded.

Index

Constants

View Source
const (
	Silent       = "0"
	MessageWarn  = "1"
	MessageError = "2"
	Notification = "4"
	Page         = "9"
)

Variables

View Source
var File_errors_proto protoreflect.FileDescriptor

Functions

func Equal

func Equal(err1 error, err2 error) bool

Equal tries to compare errors

func New

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

New generates a custom error.

Types

type Error

type Error struct {

	// Success if request is success
	Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
	// ErrorCode code for errorType
	ErrorCode string `protobuf:"bytes,2,opt,name=errorCode,proto3" json:"errorCode,omitempty"`
	// ErrorMessage message display to user
	ErrorMessage string `protobuf:"bytes,3,opt,name=errorMessage,proto3" json:"errorMessage,omitempty"`
	// ShowType error display type: 0 silent; 1 message.warn; 2 message.error; 4 notification; 9 page
	ShowType string `protobuf:"bytes,4,opt,name=showType,proto3" json:"showType,omitempty"`
	// TraceId Convenient for back-end Troubleshooting: unique request ID
	TraceId string `protobuf:"bytes,5,opt,name=traceId,proto3" json:"traceId,omitempty"`
	// Domain onvenient for backend Troubleshooting: host of current access server
	Domain string `protobuf:"bytes,6,opt,name=domain,proto3" json:"domain,omitempty"`
	// contains filtered or unexported fields
}

func FromError

func FromError(err error) *Error

FromError try to convert go error to *Error

func Parse

func Parse(errStr 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

func (*Error) GetDomain

func (x *Error) GetDomain() string

func (*Error) GetErrorCode

func (x *Error) GetErrorCode() string

func (*Error) GetErrorMessage

func (x *Error) GetErrorMessage() string

func (*Error) GetShowType

func (x *Error) GetShowType() string

func (*Error) GetSuccess

func (x *Error) GetSuccess() bool

func (*Error) GetTraceId

func (x *Error) GetTraceId() string

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

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

func (*Error) Reset

func (x *Error) Reset()

func (*Error) String

func (x *Error) String() string

type ErrorCode

type ErrorCode int32

func (ErrorCode) Code

func (e ErrorCode) Code() int32

func (ErrorCode) String

func (i ErrorCode) 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