This commit is contained in:
xiaowei.song
2024-06-06 13:19:24 +08:00
parent c93711290e
commit 127c428a9e
919 changed files with 93 additions and 86 deletions

View File

@@ -0,0 +1,37 @@
using System;
namespace Infrastructure
{
public class CustomException : Exception
{
public int Code { get; set; }
public string Msg { get; set; }
public string LogMsg { get; set; }
public CustomException(string msg) : base(msg)
{
}
public CustomException(int code, string msg) : base(msg)
{
Code = code;
Msg = msg;
}
public CustomException(ResultCode resultCode, string msg) : base(msg)
{
Code = (int)resultCode;
}
/// <summary>
/// 自定义异常
/// </summary>
/// <param name="resultCode"></param>
/// <param name="msg"></param>
/// <param name="errorMsg">用于记录详细日志到输出介质</param>
public CustomException(ResultCode resultCode, string msg, object errorMsg) : base(msg)
{
Code = (int)resultCode;
LogMsg = errorMsg.ToString();
}
}
}

View File

@@ -0,0 +1,46 @@
using System.ComponentModel;
namespace Infrastructure
{
public enum ResultCode
{
[Description("success")]
SUCCESS = 200,
[Description("传入参数为空")]
NO_DATA = 210,
[Description("参数错误")]
PARAM_ERROR = 101,
[Description("验证码错误")]
CAPTCHA_ERROR = 103,
[Description("登录错误")]
LOGIN_ERROR = 105,
[Description("操作失败")]
FAIL = 1,
[Description("服务端出错啦")]
GLOBAL_ERROR = 500,
[Description("自定义异常")]
CUSTOM_ERROR = 110,
[Description("非法请求")]
INVALID_REQUEST = 116,
[Description("授权失败")]
OAUTH_FAIL = 201,
[Description("未授权")]
DENY = 401,
[Description("授权访问失败")]
FORBIDDEN = 403,
[Description("Bad Request")]
BAD_REQUEST = 400
}
}