e

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2020 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Index

Constants

View Source
const (
	SERVER_ERROR    = 10000 //系統錯誤
	NOT_FOUND       = 10001 //找不到頁面
	UNKNOWN_ERROR   = 10002 //未知的錯誤
	PARAMETER_ERROR = 10003 //參數錯誤
	AUTH_ERROR      = 10004 //驗證錯誤
	NO_CONTENT      = 10005 //沒有內容
	DUPLICATE_ERROR = 10006 //重複資料
	SUCCESS         = 20000 //運行成功
	CREATED         = 20001 //建立成功
	ACCEPT          = 20002 //允許操作
)

Variables

This section is empty.

Functions

func HandleNotFound

func HandleNotFound(c *gin.Context)

HandleNotFound 處理404頁面

func HandleSQLError

func HandleSQLError(err string) error

HandleSQLError : 處理SQL所報的錯誤資訊

func StatusText

func StatusText(code int) string

func Wrapper

func Wrapper(handler HandlerFunc) func(c *gin.Context)

Wrapper 在 register routing 時加入錯誤 handler

Types

type APIException

type APIException struct {
	Code      int    `json:"-"`
	ErrorCode int    `json:"code"`
	Message   string `json:"message"`
	Request   string `json:"request"`
}

func AuthError

func AuthError(message string) *APIException

AuthError token 驗證錯誤

func DuplicateError

func DuplicateError(message string) *APIException

DuplicateError 重複資料

func NoContentError

func NoContentError(message string) *APIException

NoContentError 沒有資料

func NotFoundError

func NotFoundError(message string) *APIException

NotFoundError 404 錯誤

func ParameterError

func ParameterError(message string) *APIException

ParameterError 參數錯誤

func ServerError

func ServerError() *APIException

ServerError 500 伺服器錯誤

func SuccessError

func SuccessError(message string) *APIException

SuccessError 未知錯誤

func UnknownError

func UnknownError(message string) *APIException

UnknownError 未知錯誤

func (*APIException) Error

func (e *APIException) Error() string

type HandlerFunc

type HandlerFunc func(c *gin.Context) error

HandlerFunc 錯誤 handler

type Response

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
}

func StatusAccept

func StatusAccept(message string, data interface{}) (int, *Response)

func StatusCreated

func StatusCreated(message string, data interface{}) (int, *Response)

建立成功

func StatusNoContent

func StatusNoContent(message string) (int, *Response)

func StatusSuccess

func StatusSuccess(message string, data interface{}) (int, *Response)

運行成功

Jump to

Keyboard shortcuts

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