error_code.go 649 B

1234567891011121314151617181920212223242526
  1. package consts
  2. import "github.com/go-redis/redis/v8"
  3. var RedisNil = redis.Nil
  4. var errorCodeToastMap = map[int32]string{}
  5. const ErrorSuccess int32 = 0
  6. const ErrorNotLogin int32 = 4001
  7. const ErrorParamCheck int32 = 5001
  8. const ErrorInternal int32 = 5001
  9. func init() {
  10. errorCodeToastMap[ErrorSuccess] = "请求成功"
  11. errorCodeToastMap[ErrorNotLogin] = "请登录后操作"
  12. errorCodeToastMap[ErrorParamCheck] = "参数有误"
  13. errorCodeToastMap[ErrorInternal] = "网络错误"
  14. }
  15. func GetErrorToast(errorCode int32) string {
  16. toast, contain := errorCodeToastMap[errorCode]
  17. if contain {
  18. return toast
  19. }
  20. return "网络错误,请稍后再试"
  21. }