code

package
v2.0.91 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxStackDepth marks the max stack depth for error back traces.
	MaxStackDepth = 1
)

Variables

View Source
var (
	CodeLimitExceed = ApiCode{/* contains filtered or unexported fields */} // is service unavailable due to rate limit exceeded.
)

Functions

func New

func New(code int, message string, detail interface{}) gcode.Code

New creates and returns an error code. Note that it returns an interface object of Code.

func WithCode

func WithCode(code gcode.Code, detail interface{}) gcode.Code

WithCode creates and returns a new error code based on given Code. The code and message is from given `code`, but the detail if from given `detail`.

Types

type ApiCode

type ApiCode struct {
	// contains filtered or unexported fields
}

ApiCode is an implementer for interface Code for internal usage only.

func (ApiCode) Code

func (c ApiCode) Code() int

Code returns the integer number of current error code.

func (ApiCode) Detail

func (c ApiCode) Detail() interface{}

Detail returns the detailed information of current error code, which is mainly designed as an extension field for error code.

func (ApiCode) Message

func (c ApiCode) Message() string

Message returns the brief message for current error code.

func (ApiCode) String

func (c ApiCode) String() string

String returns current error code as a string.

Jump to

Keyboard shortcuts

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