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

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());
}
}