
| Visual Basic (Declaration) | |
|---|---|
Public MustInherit NotInheritable Class ExceptionHelper | |
| C# | |
|---|---|
public static class ExceptionHelper | |
Some portions of code can produce exceptions. Some of these exceptions are critical, but others are not. Critical exceptions cannot be handled with internal handlers correctly. After non-critical exceptions occur all types and data still in the valid state. All non-critical exceptions can be handled (logging, user notifications, etc.) from user code.
To handle a non-critical internal exception from user code is used event InternalException. When the non-critical internal exception is not handled by subscribers of the InternalException event, the default handler will be called (if any). Assumed the internal exception is is handled when one of InternalException subscribers set CancelEventArgs.Cancel property to true.
Note: Windows.Forms version of control has a default handler, but Web hasn't.
| C# | Copy Code |
|---|---|
ExceptionHelper.InternalException +=
delegate(object sender, InternalExceptionEventArgs args)
{
// Check that sender is known control.
if (sender != pivotView)
return;
if (args.Exception is DataProviderException)
{
ShowMessage("Database connection cannot be established or broken."
+ "If the problem persist, please contact support.");
args.Cancel = true;
}
}; | |
System.Object
GrapeCity.ActiveAnalysis.ExceptionHelper
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2