mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-27 02:21:23 +08:00
add errcode func
This commit is contained in:
@@ -227,3 +227,16 @@ func GetErrorCode(err error) (errCode int) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetErrorByCode(errCode int) (error) {
|
||||
if errCode < 0 {
|
||||
return nil
|
||||
}
|
||||
for key, value := range errorsMap {
|
||||
if value == errCode {
|
||||
return key
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -10,3 +10,9 @@ func TestGetErrorCode(t *testing.T) {
|
||||
code := GetErrorCode(err)
|
||||
fmt.Println(code)
|
||||
}
|
||||
|
||||
func TestGetErrorByCode(t *testing.T) {
|
||||
code := 0
|
||||
err := GetErrorByCode(code)
|
||||
fmt.Println("[TestGetErrorByCode]:err:",err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user