package cerrors import "errors" const ( Success = 200 BadRequest = 400 Unauthorized = 401 Forbidden = 403 NotFound = 404 NotAcceptable = 406 Gone = 410 RangeNotSatisfiable = 416 ParamError = 501 InternalServerError = 500 ServiceUnavailable = 503 DataCreateError = 511 DataUpdateError = 512 DataUpdateNoneError = 515 DataReadError = 513 DataDeleteError = 514 // ContentSmsTemplateExistErr 81xx 内容维护错误码 ContentSmsTemplateExistErr = 8100 ) var ( CodeMsg = map[int]string{ Success: "成功", BadRequest: "请求出错", Unauthorized: "登录信息过期", Forbidden: "无权限访问", NotFound: "数据不存在", NotAcceptable: "服务器忙", Gone: "数据已失效", RangeNotSatisfiable: "请求参数范围不支持", ParamError: "参数错误", InternalServerError: "服务器错误", ServiceUnavailable: "服务暂不可用", DataCreateError: "数据创建失败", DataUpdateError: "数据更新失败", DataUpdateNoneError: "数据更新无效", DataReadError: "数据查询失败", DataDeleteError: "数据删除失败", ContentSmsTemplateExistErr: "短信模板已存在", } ) func Msg(code int) string { return CodeMsg[code] } func GetError(code int) error { return errors.New(Msg(code)) }