66 lines
2.1 KiB
Go
66 lines
2.1 KiB
Go
package domain
|
||
|
||
import (
|
||
mts "ark-permission/internal/lib/metric"
|
||
|
||
ers "code.30cm.net/wanderland/library-go/errors"
|
||
"code.30cm.net/wanderland/library-go/errors/code"
|
||
)
|
||
|
||
// 12 represents Scope
|
||
// 100 represents Category
|
||
// 9 represents Detail error code
|
||
// full code 12009 只會有 系統以及錯誤碼,category 是給系統判定用的
|
||
// 目前 Scope 以及分類要系統共用,係向的錯誤各自服務實作就好
|
||
|
||
const (
|
||
TokenUnexpectedSigningErrorCode = iota + 1
|
||
TokenValidateErrorCode
|
||
TokenClaimErrorCode
|
||
)
|
||
|
||
const (
|
||
RedisDelErrorCode = iota + 20
|
||
RedisPipLineErrorCode
|
||
RedisErrorCode
|
||
)
|
||
|
||
// TokenUnexpectedSigningErr 30001 Token 簽名錯誤
|
||
func TokenUnexpectedSigningErr(msg string) *ers.Err {
|
||
mts.AppErrorMetrics.AddFailure("token", "token_unexpected_sign")
|
||
return ers.NewErr(code.CloudEPPermission, code.CatInput, TokenUnexpectedSigningErrorCode, msg)
|
||
}
|
||
|
||
// TokenTokenValidateErr 30002 Token 驗證錯誤
|
||
func TokenTokenValidateErr(msg string) *ers.Err {
|
||
mts.AppErrorMetrics.AddFailure("token", "token_validate_ilegal")
|
||
return ers.NewErr(code.CloudEPPermission, code.CatInput, TokenValidateErrorCode, msg)
|
||
}
|
||
|
||
// TokenClaimError 30003 Token 驗證錯誤
|
||
func TokenClaimError(msg string) *ers.Err {
|
||
mts.AppErrorMetrics.AddFailure("token", "token_claim_error")
|
||
return ers.NewErr(code.CloudEPPermission, code.CatInput, TokenClaimErrorCode, msg)
|
||
}
|
||
|
||
// RedisDelError 30020 Redis 刪除錯誤
|
||
func RedisDelError(msg string) *ers.Err {
|
||
// 看需要建立哪些 Metrics
|
||
mts.AppErrorMetrics.AddFailure("redis", "del_error")
|
||
return ers.NewErr(code.CloudEPPermission, code.CatDB, RedisDelErrorCode, msg)
|
||
}
|
||
|
||
// RedisPipLineError 30021 Redis PipLine 錯誤
|
||
func RedisPipLineError(msg string) *ers.Err {
|
||
// 看需要建立哪些 Metrics
|
||
mts.AppErrorMetrics.AddFailure("redis", "pip_line_error")
|
||
return ers.NewErr(code.CloudEPPermission, code.CatInput, RedisPipLineErrorCode, msg)
|
||
}
|
||
|
||
// RedisError 30022 Redis 錯誤
|
||
func RedisError(msg string) *ers.Err {
|
||
// 看需要建立哪些 Metrics
|
||
mts.AppErrorMetrics.AddFailure("redis", "error")
|
||
return ers.NewErr(code.CloudEPPermission, code.CatInput, RedisErrorCode, msg)
|
||
}
|