e

package
v2.0.0-...-0229899 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

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 StatusBadGateway

func StatusBadGateway(message string) *APIException

StatusBadGateway 502

func StatusBadRequest

func StatusBadRequest(message string) *APIException
400 系列

StatusBadRequest 400

func StatusConflict

func StatusConflict(message string) *APIException

StatusConflict 409

func StatusForbidden

func StatusForbidden(message string) *APIException

StatusForbidden 403

func StatusGatewayTimeout

func StatusGatewayTimeout(message string) *APIException

StatusGatewayTimeout 504

func StatusInternalServerError

func StatusInternalServerError() *APIException
500 系列

ServerError 500 伺服器錯誤

func StatusNotFound

func StatusNotFound(message string) *APIException

NotFoundError 404 錯誤

func StatusNotImplemented

func StatusNotImplemented(message string) *APIException

StatusNotImplemented 501

func StatusServiceUnavailable

func StatusServiceUnavailable(message string) *APIException

StatusServiceUnavailable 503

func StatusUnauthorized

func StatusUnauthorized(message string) *APIException

StatusUnauthorized 401

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 StatusAccepted

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

func StatusCreated

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

建立成功

func StatusNoContent

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

StatusNoContent 沒有資料

func StatusOK

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

運行成功

Jump to

Keyboard shortcuts

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