1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 09:36:34 -05:00

Error code check

This commit is contained in:
V2Ray 2015-09-24 22:24:00 +02:00
parent e83eec9479
commit 1995594b98

View File

@ -1,5 +1,10 @@
package unit
import (
"fmt"
"strings"
)
type ErrorSubject struct {
*Subject
value error
@ -36,3 +41,10 @@ func (subject *ErrorSubject) IsNil() {
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
}
}
func (subject *ErrorSubject) HasCode(code int) {
errorPrefix := fmt.Sprintf("[Error 0x%04X]", code)
if !strings.Contains(subject.value.Error(), errorPrefix) {
subject.FailWithMessage(fmt.Sprintf("Not ture that %s has error code 0x%04X.", subject.DisplayString(), code))
}
}