custom

package
v0.0.0-...-8c4fe33 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

@Author: Ciusyan 2023/2/14

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeMsg

type CodeMsg struct {
	// 状态码
	StatusCode int32 `json:"status_code"`
	// 消息
	StatusMsg string `json:"status_msg"`
}

func Bad

func Bad(msg string) *CodeMsg

func New

func New(c int32, msg string) *CodeMsg

New returns a CodeMsg representing c and msg.

func NewWithCode

func NewWithCode(code constant.StatusCode) *CodeMsg

func NewWithMsg

func NewWithMsg(msg string) *CodeMsg

func Newf

func Newf(c int32, format string, a ...interface{}) *CodeMsg

Newf returns New(c, fmt.Sprintf(format, a...)).

func Ok

func Ok(msg string) *CodeMsg

func (*CodeMsg) Code

func (s *CodeMsg) Code() int32

Code returns the status code contained in s.

func (*CodeMsg) Err

func (s *CodeMsg) Err() error

Err returns an immutable error representing s; returns nil if s.StatusCode() is OK.

func (*CodeMsg) Message

func (s *CodeMsg) Message() string

Message returns the message contained in s.

func (*CodeMsg) String

func (s *CodeMsg) String() string

type Exception

type Exception struct {
	S *CodeMsg
	// 可携带额外消息
	Details []interface{} `json:"details"`
}

Exception 异常对象

func (*Exception) CodeMsg

func (e *Exception) CodeMsg() *CodeMsg

func (*Exception) Error

func (e *Exception) Error() string

func (*Exception) GetDetails

func (e *Exception) GetDetails() []interface{}

GetDetails 获取额外信息

func (*Exception) Is

func (e *Exception) Is(target error) bool

Is 判断是否是自定义异常

Jump to

Keyboard shortcuts

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