mirror of https://github.com/v2ray/v2ray-core
				
				
				
			Error code check
							parent
							
								
									e83eec9479
								
							
						
					
					
						commit
						1995594b98
					
				|  | @ -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)) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 V2Ray
						V2Ray