SpringError

package module
v0.0.0-...-a3d4acf Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

go-spring-error

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERROR   = NewRpcError(-1, "ERROR")
	SUCCESS = NewRpcSuccess(200, "SUCCESS")
	DEFAULT = NewErrorCode(math.MaxInt32, "DEFAULT")
)

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode struct {
	Code int32  `json:"code"` // 错误码
	Msg  string `json:"msg"`  // 错误信息
}

ErrorCode 错误码

func NewErrorCode

func NewErrorCode(code int32, msg string) ErrorCode

NewErrorCode ErrorCode 的构造函数

type RpcError

type RpcError ErrorCode

RpcError 定义一个 RPC 异常值

func NewRpcError

func NewRpcError(code int32, msg string) RpcError

NewRpcError RpcError 的构造函数

func (RpcError) Error

func (r RpcError) Error(err error) *RpcResult

Error 绑定一个错误

func (RpcError) Panic

func (r RpcError) Panic(err error) *SpringUtils.PanicCond

Panic 抛出一个异常值

func (RpcError) PanicImmediately

func (r RpcError) PanicImmediately(err error)

PanicImmediately 立即抛出一个异常值

func (RpcError) Panicf

func (r RpcError) Panicf(format string, a ...interface{}) *SpringUtils.PanicCond

Panicf 抛出一段需要格式化的错误字符串

type RpcResult

type RpcResult struct {
	ErrorCode

	Err  string      `json:"err,omitempty"`  // 错误源
	Data interface{} `json:"data,omitempty"` // 返回值
}

RpcResult 定义 RPC 返回值

func NewRpcResult

func NewRpcResult(data interface{}) RpcResult

NewRpcResult RpcResult 的构造函数

type RpcSuccess

type RpcSuccess ErrorCode

RpcSuccess 定义一个 RPC 成功值

func NewRpcSuccess

func NewRpcSuccess(code int32, msg string) RpcSuccess

NewRpcSuccess RpcSuccess 的构造函数

func (RpcSuccess) Data

func (r RpcSuccess) Data(data interface{}) *RpcResult

Data 绑定一个值

Jump to

Keyboard shortcuts

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