You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.5 KiB
66 lines
1.5 KiB
using System.Text;
|
|
|
|
namespace Cis.Application.Core.Component.ZLMediaKit;
|
|
|
|
public class ZlmException : Exception
|
|
{
|
|
public ZlmException() : base()
|
|
{
|
|
}
|
|
|
|
public ZlmException(string message) : base(message)
|
|
{
|
|
}
|
|
|
|
public ZlmException(string message, Exception innerException) : base(message, innerException)
|
|
{
|
|
}
|
|
|
|
protected class ZlmExceptionObj
|
|
{
|
|
public ZlmCode Code { get; set; }
|
|
|
|
public string Msg { get; set; }
|
|
|
|
public int Result { get; set; }
|
|
|
|
public override string ToString()
|
|
{
|
|
StringBuilder builder = new();
|
|
builder.Append($"Code:{Code.ToInt()}({Code}), Msg:{Msg}");
|
|
if (Result < 0) builder.Append($", Result:{Result}");
|
|
return builder.ToString();
|
|
}
|
|
}
|
|
|
|
public static ZlmException New(ZlmCode code, string msg)
|
|
{
|
|
ZlmExceptionObj obj = new()
|
|
{
|
|
Code = code,
|
|
Msg = msg
|
|
};
|
|
return new ZlmException(obj.ToString());
|
|
}
|
|
|
|
public static ZlmException New(ZlmCode code, string msg, int result)
|
|
{
|
|
ZlmExceptionObj obj = new()
|
|
{
|
|
Code = code,
|
|
Msg = msg,
|
|
Result = result
|
|
};
|
|
return new ZlmException(obj.ToString());
|
|
}
|
|
}
|
|
|
|
public enum ZlmCode
|
|
{
|
|
Success = 0, //执行成功
|
|
OtherFailed = -1, //业务代码执行失败
|
|
AuthFailed = -100, //鉴权失败
|
|
SqlFailed = -200, //sql执行失败
|
|
InvalidArgs = -300, //参数不合法
|
|
Exception = -400, //代码抛异常
|
|
}
|