patrick
2019-12-10 1c4426810c71eead57084be8a18ade8d314dd8c4
src/Bro.Common.Model/Helper/ExceptionHelper.cs
@@ -8,8 +8,17 @@
namespace Bro.Common.Helper
{
    public enum ExceptionLevel
    {
        Info = 0,
        Warning = 1,
        Fatal = 2,
    }
    public class ProcessException : Exception
    {
        public ExceptionLevel Level { get; set; } = ExceptionLevel.Warning;
        public static Action<DateTime, string, string> OnExceptionNotice;
        //PubSubCenter pubSub = PubSubCenter.GetInstance();
@@ -38,9 +47,11 @@
        {
        }
        public ProcessException(Exception ex)
        public ProcessException(Exception ex, ExceptionLevel lvl = ExceptionLevel.Warning)
        {
            OriginalException = ex;
            Level = lvl;
            ExceptionNotice();
        }
@@ -50,9 +61,10 @@
        //    PositionIndex = positionIndex;
        //}
        public ProcessException(string error, Exception ex = null) : base(error, ex)
        public ProcessException(string error, ExceptionLevel lvl = ExceptionLevel.Warning, Exception ex = null) : base(error, ex)
        {
            ErrorCode = error;
            Level = lvl;
            OriginalException = ex;
            ExceptionNotice();
@@ -74,29 +86,5 @@
            //pubSub.Publish(PubTag.ExceptionUpdate.ToString(), ErrorCode, OriginalException, true);
            OnExceptionNotice?.Invoke(DateTime.Now, ErrorCode, OriginalException?.GetExceptionMessage());
        }
    }
    public class Level3Exception : ProcessException
    {
        public Level3Exception() : base() { }
        public Level3Exception(string error, Exception ex) : base(error, ex) { }
    }
    /// <summary>
    /// 来料检测异常
    /// </summary>
    public class IncomingMaterialException : ProcessException
    {
        public IncomingMaterialException() : base() { }
        public IncomingMaterialException(string error, Exception ex) : base(error, ex) { }
    }
    public class BarcodeScanFailureException : ProcessException
    {
        public BarcodeScanFailureException() : base() { }
        public BarcodeScanFailureException(string msg, Exception ex) : base(msg, ex) { }
    }
}