优化错误处理

This commit is contained in:
M09Ic 2022-11-17 05:53:04 +08:00
parent 7d67e81cb0
commit bfda87826a
2 changed files with 9 additions and 3 deletions

View File

@ -299,7 +299,7 @@ func (p *Pool) BaseCompare(bl *pkg.Baseline) {
if ok {
if status = base.Compare(bl); status == 1 {
p.PutToInvalid(bl, "compare failed")
p.PutToInvalid(bl, ErrCompareFailed.Error())
return
}
}
@ -307,13 +307,13 @@ func (p *Pool) BaseCompare(bl *pkg.Baseline) {
bl.Collect()
for _, f := range bl.Frameworks {
if f.Tag == "waf/cdn" {
p.PutToInvalid(bl, "waf")
p.PutToInvalid(bl, ErrWaf.Error())
return
}
}
if ok && status == 0 && base.FuzzyCompare(bl) {
p.PutToInvalid(bl, "fuzzy compare failed")
p.PutToInvalid(bl, ErrFuzzyCompareFailed.Error())
p.PutToFuzzy(bl)
return
}

View File

@ -8,6 +8,8 @@ const (
ErrRequestFailed
ErrWaf
ErrRedirect
ErrCompareFailed
ErrFuzzyCompareFailed
)
func (e ErrorType) Error() string {
@ -22,6 +24,10 @@ func (e ErrorType) Error() string {
return "maybe ban of waf"
case ErrRedirect:
return "duplicate redirect url"
case ErrCompareFailed:
return "compare failed"
case ErrFuzzyCompareFailed:
return "fuzzy compare failed"
default:
return "unknown error"
}