12345678910111213141516171819202122232425262728293031323334353637 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package errors
- import (
- "google.golang.org/grpc/codes"
- "google.golang.org/grpc/status"
- )
- var (
- // 通用错误
- SystemError = status.Error(10001, "系统错误")
- ServiceError = status.Error(10002, "内部服务错误")
- ParamsError = status.Error(10003, "参数错误")
- DataBaseError = status.Error(10004, "数据库错误")
- KeyError = status.Error(10005, "AppKey错误")
- NoDeleteError = status.Error(10006, "无待删除员工")
- NoDownloadError = status.Error(10007, "无待下发员工")
- SnNotExistError = status.Error(10008, "设备序列号不存在")
- )
- func ErrorTransForm(err error) error {
- if err == nil {
- return nil
- }
- errStatus := status.Convert(err)
- code := errStatus.Code()
- //msg := errStatus.Message()
- if code == codes.Unknown {
- return ServiceError
- }
- return err
- }
|