初始刷
This commit is contained in:
48
Infrastructure/CustomException/CustomException.cs
Normal file
48
Infrastructure/CustomException/CustomException.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System;
|
||||
|
||||
namespace Infrastructure
|
||||
{
|
||||
public class CustomException : Exception
|
||||
{
|
||||
public int Code { get; set; }
|
||||
/// <summary>
|
||||
/// 前端提示语
|
||||
/// </summary>
|
||||
public string Msg { get; set; }
|
||||
/// <summary>
|
||||
/// 记录到日志的详细内容
|
||||
/// </summary>
|
||||
public string LogMsg { get; set; }
|
||||
/// <summary>
|
||||
/// 是否通知
|
||||
/// </summary>
|
||||
public bool Notice { get; set; } = true;
|
||||
|
||||
public CustomException(string msg) : base(msg)
|
||||
{
|
||||
}
|
||||
public CustomException(int code, string msg) : base(msg)
|
||||
{
|
||||
Code = code;
|
||||
Msg = msg;
|
||||
}
|
||||
|
||||
public CustomException(ResultCode resultCode, string msg, bool notice = true) : base(msg)
|
||||
{
|
||||
Code = (int)resultCode;
|
||||
Notice = notice;
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
}
|
||||
}
|
||||
49
Infrastructure/CustomException/ResultCode.cs
Normal file
49
Infrastructure/CustomException/ResultCode.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
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("请先绑定手机号")]
|
||||
PHONE_BIND = 202,
|
||||
|
||||
[Description("未授权")]
|
||||
DENY = 401,
|
||||
|
||||
[Description("授权访问失败")]
|
||||
FORBIDDEN = 403,
|
||||
|
||||
[Description("Bad Request")]
|
||||
BAD_REQUEST = 400
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user