golang-im聊天
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
772 B

  1. package gerrors
  2. import (
  3. "google.golang.org/grpc/codes"
  4. "google.golang.org/grpc/status"
  5. )
  6. var (
  7. ErrUnknown = status.New(codes.Unknown, "服务器异常").Err() // 服务器未知错误
  8. ErrUnauthorized = newError(10000, "请重新登录")
  9. ErrBadRequest = newError(10001, "请求参数错误")
  10. ErrBadCode = newError(10010, "验证码错误")
  11. ErrNotInGroup = newError(10011, "用户没有在群组中")
  12. ErrGroupNotExist = newError(10013, "群组不存在")
  13. ErrDeviceNotExist = newError(10014, "设备不存在")
  14. ErrAlreadyIsFriend = newError(10015, "对方已经是好友了")
  15. ErrUserNotFound = newError(10016, "用户找不到")
  16. )
  17. func newError(code int, message string) error {
  18. return status.New(codes.Code(code), message).Err()
  19. }