Documentation
¶
Index ¶
- Constants
- Variables
- func SubCodeForCode(code int) string
- type AppError
- func New(code int, subCode, message string) *AppError
- func NewCode(code int, message string) *AppError
- func NewCodeWithData(code int, message string, data interface{}) *AppError
- func NewWithData(code int, subCode, message string, data interface{}) *AppError
- func Wrap(err error, code int, subCode, message string) *AppError
- func WrapWithData(err error, code int, subCode, message string, data interface{}) *AppError
Constants ¶
View Source
const ( CodeOK = 200 CodeBadRequest = 400 CodeForbidden = 403 CodeNotFound = 404 CodeConflict = 409 CodeInternal = 500 CodeBusinessError = 3000 CodeBusinessDuplicated = 3002 CodeBusinessProtected = 3003 CodeBusinessConflict = 3004 CodeAuthRequired = 4001 CodeOperationFailed = 5001 CodeQueueTaskConflict = 4091 )
View Source
const ( SubCodeBadRequest = "BAD_REQUEST" SubCodeValidation = "VALIDATION_ERROR" SubCodeJSONType = "JSON_TYPE_ERROR" SubCodeForbidden = "FORBIDDEN" SubCodeNotFound = "NOT_FOUND" SubCodeConflict = "CONFLICT" SubCodeInternal = "INTERNAL_ERROR" SubCodeInvalidCredentials = "INVALID_CREDENTIALS" SubCodeAccountDisabled = "ACCOUNT_DISABLED" SubCodeLoginFailed = "LOGIN_FAILED" SubCodeUserNotFound = "USER_NOT_FOUND" SubCodeRoleQueryFailed = "ROLE_QUERY_FAILED" SubCodeSecurityCheckFailed = "SECURITY_CHECK_FAILED" SubCodeBusinessError = "BUSINESS_ERROR" SubCodeBusinessDuplicated = "BUSINESS_DUPLICATED" SubCodeBusinessProtected = "BUSINESS_PROTECTED" SubCodeBusinessConflict = "BUSINESS_CONFLICT" SubCodeAuthRequired = "AUTH_REQUIRED" SubCodeOperationFailed = "OPERATION_FAILED" SubCodeQueueTaskConflict = "QUEUE_TASK_CONFLICT" )
Variables ¶
View Source
var ( ErrBadRequest = New(CodeBadRequest, SubCodeBadRequest, "请求参数错误") ErrForbidden = New(CodeForbidden, SubCodeForbidden, "禁止访问") ErrNotFound = New(CodeNotFound, SubCodeNotFound, "资源不存在") ErrConflict = New(CodeConflict, SubCodeConflict, "资源冲突") ErrInternalServer = New(CodeInternal, SubCodeInternal, "服务器内部错误") )
Functions ¶
func SubCodeForCode ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.