refactor: 自定义业务错误 (#33)

* refactor: 自定义业务错误

* refactor: 隐藏服务器错误与统一 panic 响应
This commit is contained in:
NepetaLemon
2025-12-26 08:47:00 +08:00
committed by GitHub
parent b31698b9f2
commit 8d7a497553
8 changed files with 158 additions and 11 deletions

View File

@@ -7,8 +7,9 @@ import (
)
const (
UnknownCode = http.StatusInternalServerError
UnknownReason = ""
UnknownCode = http.StatusInternalServerError
UnknownReason = ""
UnknownMessage = "internal error"
)
type Status struct {
@@ -153,5 +154,5 @@ func FromError(err error) *ApplicationError {
}
// Fall back to a generic internal error.
return New(UnknownCode, UnknownReason, err.Error()).WithCause(err)
return New(UnknownCode, UnknownReason, UnknownMessage).WithCause(err)
}