types

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: GPL-3.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound            = NewHttpError(http.StatusNotFound)
	ErrBadRequest          = NewHttpError(http.StatusBadRequest)
	ErrServiceUnavailable  = NewHttpError(http.StatusServiceUnavailable)
	ErrInternalServerError = NewHttpError(http.StatusInternalServerError)
)

Functions

func IsError

func IsError(err error) bool

Types

type Error

type Error struct {
	Code     int    `json:"code"`
	Key      string `json:"error,omitempty"`
	Success  bool   `json:"success"`
	Message  string `json:"message"`
	Internal error  `json:"-"`
}

Error 异常结构

func ErrorOf

func ErrorOf(err error) *Error

func NewError

func NewError(code int, message ...string) *Error

func NewHttpError

func NewHttpError(code int, message ...string) *Error

func (Error) Error

func (err Error) Error() string

type Result

type Result struct {
	Code    int         `json:"code"`
	Success bool        `json:"success,omitempty"`
	Message interface{} `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

Result 返回结果

func ResultNilData

func ResultNilData(code int) *Result

Result 无Data

func ResultOf

func ResultOf(code int, data interface{}) *Result

Result 构造Result

Jump to

Keyboard shortcuts

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