using System.Text; namespace EC.Helper.CameraSDK; /// /// 相机异常 /// 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 CameraManufactor Manufactor { get; set; } public int Code { get; set; } public string? Msg { get; set; } public override string? ToString() { StringBuilder builder = new(); builder.Append($"Manufactor:{Manufactor}, Code:{Code}"); if (!string.IsNullOrEmpty(Msg)) builder.Append($", Msg:{Msg}"); return builder.ToString(); } } public static CameraException New(CameraManufactor manufactor, int code) { CameraExceptionObj obj = new() { Manufactor = manufactor, Code = code }; return new CameraException(obj.ToString()); } public static CameraException New(CameraManufactor manufactor, int code, string msg) { CameraExceptionObj obj = new() { Manufactor = manufactor, Code = code, Msg = msg }; return new CameraException(obj.ToString()); } }