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.

59 lines
1.4 KiB

2 years ago
using System.Text;
namespace EC.Util.CameraSDK;
/// <summary>
/// 相机异常
/// </summary>
public class CameraException : Exception
{
public CameraException() : base()
{
}
public CameraException(string? message) : base(message)
{
}
public CameraException(string? message, Exception? innerException) : base(message, innerException)
{
}
protected class CameraExceptionObj
{
public CameraInfo? CameraInfo { get; set; }
2 years ago
public int Code { get; set; }
public string? Msg { get; set; }
public override string? ToString()
{
StringBuilder builder = new();
builder.Append($"Ip:{CameraInfo?.Ip}, Manufactor:{CameraInfo?.Manufactor}, Code:{Code}");
2 years ago
if (!string.IsNullOrEmpty(Msg)) builder.Append($", Msg:{Msg}");
return builder.ToString();
}
}
public static CameraException New(CameraInfo cameraInfo, int code)
2 years ago
{
CameraExceptionObj obj = new()
{
CameraInfo = cameraInfo,
2 years ago
Code = code
};
return new CameraException(obj.ToString());
}
public static CameraException New(CameraInfo cameraInfo, int code, string msg)
2 years ago
{
CameraExceptionObj obj = new()
{
CameraInfo = cameraInfo,
2 years ago
Code = code,
Msg = msg
};
return new CameraException(obj.ToString());
}
}