通用错误处理

    public class BizException : Exception
    {
        public BizException()
        {
        }

        public BizException(BizExceptionType o)
        {
            Utility.GeneralLog(o.ToString());
            myType = o;
        }

        private BizExceptionType myType = BizExceptionType.DefaultException;

        public BizExceptionType MyType
        {
            get { return myType; }
            set { myType = value; }
        }
    } 
public enum BizExceptionType
    {
        DefaultException, //default
}


throw new BizException(BizExceptionType.DefaultException);
            try
            {

            }
            catch (BizException ex)
            {
                log.Error(ex.MyType.ToString());
                throw new SoapException(ex.MyType.ToString(), new System.Xml.XmlQualifiedName(ex.MyType.ToString()));
            }
            catch (Exception ex)
            {
                log.Error(ex.ToString());
                throw ex;
            }
原文地址:https://www.cnblogs.com/xh831213/p/2299408.html