12345678910111213141516171819202122232425262728293031323334353637 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package errors
- import (
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
- )
- var (
- // 通用错误
- SystemError = status.Error(10001, "系统错误")
- ParamsError = status.Error(10002, "参数错误")
- NotFoundError = status.Error(10003, "无数据")
- DuplicateError = status.Error(10004, "数据重复")
- AppKeyNotExistError = status.Error(10005, "AppKey不能为空")
- AppKeyNotExist1Error = status.Error(10006, "AppKey不存在")
- SignNotExistError = status.Error(10007, "签名不能为空")
- SignNotCorrectError = status.Error(10007, "签名错误")
- TimeStampNotExistError = status.Error(10007, "时间戳不能为空")
- )
- func ErrorTransForm(err error) error {
- if err == nil {
- return nil
- }
- errStatus := status.Convert(err)
- code := errStatus.Code()
- if code == codes.Unknown || code == codes.Unavailable || code == codes.Internal {
- return SystemError
- }
- return err
- }
|