feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
package errors
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
// 用户相关错误
|
test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
2026-04-17 20:43:50 +08:00
|
|
|
ErrUserNotFound = errors.New("用户不存在")
|
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
ErrUsernameExists = errors.New("用户名已存在")
|
|
|
|
|
ErrEmailExists = errors.New("邮箱已存在")
|
|
|
|
|
ErrPhoneExists = errors.New("手机号已存在")
|
|
|
|
|
ErrInvalidCredentials = errors.New("用户名或密码错误")
|
|
|
|
|
ErrAccountLocked = errors.New("账号已被锁定")
|
|
|
|
|
ErrAccountDisabled = errors.New("账号已被禁用")
|
|
|
|
|
ErrInvalidOldPassword = errors.New("原密码错误")
|
|
|
|
|
|
|
|
|
|
// 角色相关错误
|
test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
2026-04-17 20:43:50 +08:00
|
|
|
ErrRoleNotFound = errors.New("角色不存在")
|
|
|
|
|
ErrRoleCodeExists = errors.New("角色代码已存在")
|
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
ErrCannotModifySystemRole = errors.New("不能修改系统角色")
|
|
|
|
|
ErrCannotDeleteSystemRole = errors.New("不能删除系统角色")
|
test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
2026-04-17 20:43:50 +08:00
|
|
|
ErrRoleInUse = errors.New("角色正在使用中")
|
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
|
|
|
|
|
// 权限相关错误
|
|
|
|
|
ErrPermissionNotFound = errors.New("权限不存在")
|
|
|
|
|
ErrPermissionCodeExists = errors.New("权限代码已存在")
|
|
|
|
|
|
|
|
|
|
// 通用错误
|
test: add comprehensive test coverage and improve code quality
- Add new test files for auth, service, and handler modules
- Improve test organization and coverage
- Refactor code for better maintainability
- Add captcha, settings, stats, and theme handler tests
- Add auth module tests (CAS, OAuth, password, SSO, state)
- Add service layer tests for auth, export, permissions, roles
- All Go tests pass (exit code 0)
- All frontend tests pass (325 tests in 59 files)
2026-04-17 20:43:50 +08:00
|
|
|
ErrInvalidParams = errors.New("参数错误")
|
|
|
|
|
ErrUnauthorized = errors.New("未授权")
|
|
|
|
|
ErrForbidden = errors.New("无权限")
|
feat: backend core - auth, user, role, permission, device, webhook, monitoring, cache, repository, service, middleware, API handlers
2026-04-02 11:19:50 +08:00
|
|
|
ErrInternalServerError = errors.New("服务器内部错误")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// NewError 创建新错误
|
|
|
|
|
func NewError(msg string) error {
|
|
|
|
|
return errors.New(msg)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// WrapError 包装错误
|
|
|
|
|
func WrapError(err error, msg string) error {
|
|
|
|
|
if err == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
return fmt.Errorf("%s: %w", msg, err)
|
|
|
|
|
}
|