// 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, "数据库错误") RedisError = status.Error(10005, "Redis错误") OssError = status.Error(10006, "对象存储服务错误") OssObjNotExist = status.Error(10006, "文件不存在") OssFileTooBig = status.Error(10006, "文件不能超过10M") NoTokenError = status.Error(10008, "没有token") TokenExpiredError = status.Error(10009, "token已过期") TokenFailedError = status.Error(10010, "token错误") PermissionError = status.Error(10011, "权限不足") PermissionErrorNoRouter = status.Error(10012, "权限不足未设置该路由") ErrRecordNotFound = status.Error(10012, "数据不存在") PermissionChangedError = status.Error(19999, "权限变动,请重新获取") ) 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 }