response

package
v0.0.0-...-ad8f053 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//
	ParameterIsInvalidCode = 1000 + iota
	//
	UserNotFoundCode
	//
	UserAlreadyBlockCode
	//
	UserAlreadyExistsCode
	//
	UserRegisterFailedCode
	//
	PasswordIncorrectCode
	//
	RecordNotExitsCode
	//
	RecordQueryFaildCode
	//
	RecordCreateFaildCode
	//
	RecordDeleteFailedCode
	//
	RecordUpdateFailedCode
	//
	AccountAuthorizeFailedCode
	//
	ServerErrorCode
	//
	RouterNotFoundCodeCode
	//
	RouterAuthorityLimitCode
)

自定义状态码

Variables

View Source
var ErrAccountAuthorizeFailed = NewException("Errors.AccountAuthorizeFailed", http.StatusNonAuthoritativeInfo, AccountAuthorizeFailedCode)
View Source
var ErrAccountPermissionLimit = NewException("Errors.AccountPermissionLimit", http.StatusNonAuthoritativeInfo, AccountAuthorizeFailedCode)
View Source
var ErrInternalServer = NewException("Errors.ServerError", http.StatusInternalServerError, ServerErrorCode)
View Source
var ErrParameterIsInvalid = NewException("Errors.ParameterIsInvalid", http.StatusBadRequest, ParameterIsInvalidCode)
View Source
var ErrPasswordIncorrect = NewException("Errors.PasswordIncorrect", http.StatusBadRequest, PasswordIncorrectCode)
View Source
var ErrRecordCreateFaild = NewException("Errors.RecordCreateFaild", http.StatusBadRequest, RecordCreateFaildCode)
View Source
var ErrRecordDeleteFailed = NewException("Errors.RecordDeleteFaild", http.StatusBadRequest, RecordDeleteFailedCode)
View Source
var ErrRecordNotExits = NewException("Errors.RecordNotExits", http.StatusNotFound, RecordNotExitsCode)
View Source
var ErrRecordQueryFaild = NewException("Errors.RecordQueryFaild", http.StatusBadRequest, RecordQueryFaildCode)
View Source
var ErrRecordUpdateFailed = NewException("Errors.RecordUpdateFaild", http.StatusBadRequest, RecordUpdateFailedCode)
View Source
var ErrRouterForbidden = NewException("Errors.RouterForbidden", http.StatusForbidden, RouterAuthorityLimitCode)
View Source
var ErrRouterNotFound = NewException("Errors.RouterNotFound", http.StatusNotFound, RouterNotFoundCodeCode)
View Source
var ErrUserAlreadyBlock = NewException("Errors.UserAlreadyBlock", http.StatusBadRequest, UserAlreadyBlockCode)
View Source
var ErrUserAlreadyExists = NewException("Errors.UserAlreadyExists", http.StatusBadRequest, UserAlreadyExistsCode)
View Source
var ErrUserNotFound = NewException("Errors.UserNotFound", http.StatusNotFound, UserNotFoundCode)
View Source
var ErrUserRegisterFailed = NewException("Errors.UserRegisterFailed", http.StatusBadRequest, UserRegisterFailedCode)

Functions

func FailWithResponse

func FailWithResponse(ctx *gin.Context, err error)

func OkWithResponse

func OkWithResponse(ctx *gin.Context, data any)

func Response

func Response(ctx *gin.Context, message string, data any, status int, code int)

Types

type Exception

type Exception struct {
	// contains filtered or unexported fields
}

func NewException

func NewException(message string, status int, code int) *Exception

func (*Exception) Code

func (e *Exception) Code() int

func (*Exception) Error

func (e *Exception) Error() string

func (*Exception) ErrorMessage

func (e *Exception) ErrorMessage() map[string]string

func (*Exception) SetErrorMessage

func (e *Exception) SetErrorMessage(field string, message string)

func (*Exception) SetMessage

func (e *Exception) SetMessage(message string)

func (*Exception) Status

func (e *Exception) Status() int

Jump to

Keyboard shortcuts

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