尝试登录逻辑
This commit is contained in:
27
srv/internal/ero/error.go
Normal file
27
srv/internal/ero/error.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package ero
|
||||
|
||||
import "net/http"
|
||||
|
||||
type Type int
|
||||
|
||||
const (
|
||||
// ServerError 通用的,不需要特殊处理暴露给前端的错误
|
||||
ServerError Type = iota
|
||||
// FormError 表单校验异常,没有执行成功。Data 内会有明确的字段级错误返回给前端处理
|
||||
FormError
|
||||
)
|
||||
|
||||
// GeneralError 通用的错误数据包装
|
||||
type GeneralError struct {
|
||||
Status int
|
||||
// Type 错误类型,参考自定义类型 Type
|
||||
Type Type
|
||||
// Message 当前错误的简短解释
|
||||
Message string
|
||||
// Data 如果是复杂错误,此处会返回前端协助前端展示错误的数据
|
||||
Data any
|
||||
}
|
||||
|
||||
func SimpleError(msg string) *GeneralError {
|
||||
return &GeneralError{http.StatusInternalServerError, ServerError, msg, nil}
|
||||
}
|
||||
Reference in New Issue
Block a user