mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-02-20 23:47:21 -05:00
Error code check
This commit is contained in:
parent
e83eec9479
commit
1995594b98
@ -1,5 +1,10 @@
|
|||||||
package unit
|
package unit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
type ErrorSubject struct {
|
type ErrorSubject struct {
|
||||||
*Subject
|
*Subject
|
||||||
value error
|
value error
|
||||||
@ -36,3 +41,10 @@ func (subject *ErrorSubject) IsNil() {
|
|||||||
subject.FailWithMessage("Not true that " + subject.DisplayString() + " is nil.")
|
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))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user