|
|
|
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; }
|
|
|
|
|
|
|
|
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}");
|
|
|
|
if (!string.IsNullOrEmpty(Msg)) builder.Append($", Msg:{Msg}");
|
|
|
|
return builder.ToString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CameraException New(CameraInfo cameraInfo, int code)
|
|
|
|
{
|
|
|
|
CameraExceptionObj obj = new()
|
|
|
|
{
|
|
|
|
CameraInfo = cameraInfo,
|
|
|
|
Code = code
|
|
|
|
};
|
|
|
|
return new CameraException(obj.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
public static CameraException New(CameraInfo cameraInfo, int code, string msg)
|
|
|
|
{
|
|
|
|
CameraExceptionObj obj = new()
|
|
|
|
{
|
|
|
|
CameraInfo = cameraInfo,
|
|
|
|
Code = code,
|
|
|
|
Msg = msg
|
|
|
|
};
|
|
|
|
return new CameraException(obj.ToString());
|
|
|
|
}
|
|
|
|
}
|