respcode

package
v0.0.0-...-3894622 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUCCESS          = 200
	ERROR            = 500
	BadRequest       = 400
	Unauthorized     = 401
	Forbidden        = 403
	NotFound         = 404
	MethodNotAllowed = 405

	UserError             = 1000
	ErrorUsernameUsed     = 1001
	ErrorPasswordWrong    = 1002
	ErrorUserNotExist     = 1003
	ErrorUserInactive     = 1004
	ErrorEmailUsed        = 1005
	ErrorInvalidEmail     = 1006
	ErrorInvalidRole      = 1007
	ErrorEmptyDisplayName = 1008
	ErrorInvalidAvatarURL = 1009

	AuthError         = 2000
	ErrorTokenInvalid = 2001
	ErrorNoPermission = 2002

	CategoryError      = 3000
	ErrorCateNameUsed  = 3001
	ErrorCateNotExist  = 3002
	ErrorEmptyCateName = 3003

	ArticleError       = 4000
	ErrorArtNotExist   = 4001
	ErrorArtTitleEmpty = 4002
	ErrorArtContent    = 4003

	ErrorPasswordTooShort = 1010
)

Variables

This section is empty.

Functions

func GetErrMsg

func GetErrMsg(code int) string

func GetHTTPStatus

func GetHTTPStatus(code int) int

func IsClientError

func IsClientError(code int) bool

func IsServerError

func IsServerError(code int) bool

func IsSuccess

func IsSuccess(code int) bool

Types

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Detail  string `json:"detail,omitempty"`
}

func NewError

func NewError(code int, detail string) ErrorResponse

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

Jump to

Keyboard shortcuts

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