add errcode func

This commit is contained in:
张开元
2024-12-19 20:26:39 +08:00
parent dcd252f802
commit ed8fdebc81
2 changed files with 19 additions and 0 deletions

View File

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