using System;
using System.Runtime.Serialization;
namespace Znyc.Admin.AspNetCore.Common
{
///
/// 自定义异常信息
///
public class MyApiException : Exception
{
private string _msg;
private bool _success;
private string _errCode;
///
/// 异常消息
///
public string Msg
{
get => _msg;
set => _msg = value;
}
///
/// 成功状态
///
public bool Success
{
get => _success;
set => _success = value;
}
///
/// 提示代码
///
public string ErrCode
{
get => _errCode;
set => _errCode = value;
}
///
/// 异常
///
///
public MyApiException(string message)
{
Msg = message;
}
///
///
///
///
///
public MyApiException(string message, string errcode)
{
Msg = message;
ErrCode = errcode;
}
///
///
///
///
///
///
public MyApiException(string message, bool success, string errcode)
{
Msg = message;
Success = success;
ErrCode = errcode;
}
///
///
///
public MyApiException()
{
}
///
///
///
///
///
protected MyApiException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
///
///
///
///
///
public MyApiException(string message, Exception innerException) : base(message, innerException)
{
Msg = message;
throw innerException;
}
///
///
///
///
///
///
public MyApiException(string message, string errcode, Exception innerException) : base(message, innerException)
{
Msg = message;
ErrCode = errcode;
throw innerException;
}
}
}