err.go 739 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package main
  2. var (
  3. errMsg map[int]string
  4. )
  5. const (
  6. OK = iota
  7. TIME_OUT
  8. NO_RESP
  9. NO_AUTH
  10. FORMAT_ERR
  11. SERVER_BUSY
  12. ILLEGAL_REQ
  13. INNER_ERR
  14. ILLEGAL_PARM
  15. INIT_DRIVER_ERR
  16. UNKNOWN_ERR
  17. )
  18. func init() {
  19. errMsg = make(map[int]string)
  20. errMsg[0] = "成功"
  21. errMsg[1] = "网络超时"
  22. errMsg[2] = "无响应"
  23. errMsg[3] = "无权限"
  24. errMsg[4] = "格式错误"
  25. errMsg[5] = "服务繁忙"
  26. errMsg[6] = "非法请求"
  27. errMsg[7] = "内部错误"
  28. errMsg[8] = "不合法的数据,或者amount 小于等于17500"
  29. errMsg[9] = "init driver error"
  30. //errMsg[8] = "requesting transactions at unknown confirmation heights"
  31. }
  32. func GetErrMsg(ret int, data []byte) string {
  33. msg, ok := errMsg[ret]
  34. if ok {
  35. return msg
  36. }
  37. return string(data)
  38. }