temp
This commit is contained in:
20
pkg/errs/err.go
Normal file
20
pkg/errs/err.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package errs
|
||||
|
||||
// 定义自定义错误类型
|
||||
type AppError struct {
|
||||
Code int // 错误码
|
||||
Message string // 错误信息
|
||||
}
|
||||
|
||||
// 实现 error 接口的 Error 方法
|
||||
func (e *AppError) Error() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
// 创建带有错误码和错误信息的 AppError
|
||||
func NewAppError(code int, message string) *AppError {
|
||||
return &AppError{
|
||||
Code: code,
|
||||
Message: message,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user