mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-04-18 19:49:13 -04:00
Unify error checking by introducing error codes
This commit is contained in:
@@ -2,7 +2,8 @@ package unit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/v2ray/v2ray-core/common/errors"
|
||||
)
|
||||
|
||||
type ErrorSubject struct {
|
||||
@@ -43,8 +44,7 @@ func (subject *ErrorSubject) IsNil() {
|
||||
}
|
||||
|
||||
func (subject *ErrorSubject) HasCode(code int) {
|
||||
errorPrefix := fmt.Sprintf("[Error 0x%04X]", code)
|
||||
if !strings.Contains(subject.value.Error(), errorPrefix) {
|
||||
if !errors.HasCode(subject.value, code) {
|
||||
subject.FailWithMessage(fmt.Sprintf("Not ture that %s has error code 0x%04X.", subject.DisplayString(), code))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user