/* * ExceptionalUserControl.cs * * Copyright © 2009 * Diversified Technical Systems, Inc. * All Rights Reserved */ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace DTS.Common.Utilities { /// /// A version of that provides its own exception type. /// /// /// /// Sample usage: /// public class A : ExceptionalUserControl /// { /// public void ScrewItUp( ) /// { /// private bool error = true; /// if ( error ) throw new A.Exception( "Class A-specific screwup." ); /// } /// } /// /// ... /// /// try /// { /// A.ScrewItUp( ); /// B.ScrewItUp( ); /// C.ScrewItUp( ); /// } /// catch ( A.Exception ex ) /// { /// // Can pick A's exceptions out of a crowd, or not and just treat it /// // polymorphically as a System.Exception. /// } /// /// public class ExceptionalUserControl : UserControl { /// /// Initialize an instance of the ExceptionalUserControl class. /// public ExceptionalUserControl() : base() { } /// /// A representation of the DerivedClass.Exception class. /// [global::System.Serializable] public class Exception : ApplicationException { /// /// create a /// public Exception() { } /// /// create a with a description /// /// Description of error public Exception(string msg) : base(msg) { } /// /// create a with a description /// and a reference to the exception causing the error /// /// Description of error /// exception causing error public Exception(string msg, System.Exception innerEx) : base(msg, innerEx) { } protected Exception( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context) { } } } }