12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // 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(10000, "系统错误")
- ParamsError = status.Error(10001, "参数错误")
- NotFoundError = status.Error(10002, "无数据")
- DuplicateError = status.Error(10003, "数据重复")
- ServiceError = status.Error(10000, "内部服务错误")
- PassWordError = status.Error(10004, "密码错误")
- UserStatusError = status.Error(10005, "当前用户禁止登陆")
- NoTokenError = status.Error(10008, "没有token")
- TokenExpiredError = status.Error(10009, "token已过期")
- TokenFailedError = status.Error(10010, "token错误")
- FileTypeError = status.Error(10011, "文件类型错误")
- FileToLargestError = status.Error(10012, "文件太大")
- UploadTypeError = status.Error(10013, "上传类型的未知")
- FileOpenFailed = status.Error(20317, "文件打开失败")
- ExportPdfFailed = status.Error(20318, "PDF生成失败")
- ExportWordFailed = status.Error(20319, "word生成失败")
- )
- 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 ServiceError
- }
- return err
- }
|