Files
DP44/Common/DTS.Common.Utilities/ExceptionalUserControl.cs
2026-04-17 14:55:32 -04:00

86 lines
2.7 KiB
C#

/*
* 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
{
/// <summary>
/// A version of <see cref="System.Windows.Forms.UserControl"/> that provides its own exception type.
/// </summary>
///
/// <remarks>
/// 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.
/// }
/// </remarks>
///
public class ExceptionalUserControl : UserControl
{
/// <summary>
/// Initialize an instance of the ExceptionalUserControl class.
/// </summary>
public ExceptionalUserControl()
: base()
{
}
/// <summary>
/// A representation of the DerivedClass.Exception class.
/// </summary>
[global::System.Serializable]
public class Exception : ApplicationException
{
/// <summary>
/// create a <see cref="ExceptionalUserControl.Exception" />
/// </summary>
public Exception() { }
/// <summary>
/// create a <see cref="ExceptionalUserControl.Exception" /> with a description
/// </summary>
/// <param name="msg">Description of error</param>
public Exception(string msg) : base(msg) { }
/// <summary>
/// create a <see cref="ExceptionalUserControl.Exception" /> with a description
/// and a reference to the exception causing the error
/// </summary>
/// <param name="msg">Description of error</param>
/// <param name="innerEx">exception causing error</param>
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) { }
}
}
}