1
0
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:
V2Ray
2015-09-25 00:17:44 +02:00
parent 1995594b98
commit 08f85fc9b7
7 changed files with 124 additions and 53 deletions

View File

@@ -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))
}
}