WinForms

Upgrade Guide User Guide Demos Support Forums Download
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ExceptionManager - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Class ExceptionManager

    Provides a global hook for exceptions that have been cached inside the framework and gives you the option to provide specialized handling of the exception. You can also temporarily suspend and resume caching exceptions.

    Inheritance
    System.Object
    ExceptionManager
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Syncfusion.Windows.Forms
    Assembly: Syncfusion.Shared.Base.dll
    Syntax
    public class ExceptionManager
    Remarks

    The Syncfusion framework notifies ExceptionManager about exceptions that are cached by calling RaiseExceptionCatched(Object, Exception) or ExceptionManager.

    The RaiseExceptionCatched(Object, Exception) method will raise the ExceptionCatched event. By handling the ExceptionCatched event, your code can analyze the exception that was cached and optionally let it bubble up by rethrowing the exception.

    Your code can also temporarily suspend and resume caching exceptions. This is useful if you want to provide your own exception handling. Just call SuspendCatchExceptions() to disable handling exceptions and ResumeCatchExceptions() to resume caching exceptions.

    You also have the options to disable caching exceptions altogether by setting PassThroughExceptions to True.

    Note: All static settings for this class are thread local.

    Examples
                // The following example demonstrates temporarily suspending exception caching when calling a base class version
                // of a method.
                        protected override void OnMouseDown(MouseEventArgs e)
                            {
                            ExceptionManager.SuspendCatchExceptions();
                            try
                            {
                                base.OnMouseDown(e);
                                ExceptionManager.ResumeCatchExceptions();
                            }
                            catch (Exception ex)
                            {
                                ExceptionManager.ResumeCatchExceptions();
                                    // Notify exception manager about the catched exception and
                                    // give it a chance to optionally rethrow the exception if necessary
                                    // (e.g. if this OnMouseDown was called from another class that
                                    // wants to provide its own exception handling).
                                if (!ExceptionManager.RaiseExceptionCatched(this, ex))
                					throw ex;
                                // handle exception here
                                MessageBox.Show(ex.ToString());
                            }
                        }
                // This code sample shows how exceptions are handled within the framework:
                                try
                                {
                                    CurrentCell.Refresh();
                                }
                                catch (Exception ex)
                                {
                                    TraceUtil.TraceExceptionCatched(ex);
                                    if (!ExceptionManager.RaiseExceptionCatched(this, ex))
                						throw ex;
                                }

    Constructors

    ExceptionManager()

    Declaration
    public ExceptionManager()

    Properties

    PassThroughExceptions

    Lets you disable caching exceptions altogether by setting PassThroughExceptions to True.

    Declaration
    public static bool PassThroughExceptions { get; set; }
    Property Value
    Type Description
    System.Boolean

    Methods

    RaiseExceptionCatched(Object, ExceptionCatchedEventArgs)

    Raises the ExceptionCatched event. If caching exceptions has been disabled by a SuspendCatchExceptions() call or if PassThroughExceptions has been set to True, the exception is rethrown.

    Declaration
    public static bool RaiseExceptionCatched(object sender, ExceptionCatchedEventArgs e)
    Parameters
    Type Name Description
    System.Object sender
    ExceptionCatchedEventArgs e

    A ExceptionCatchedEventArgs that contains the event data.

    Returns
    Type Description
    System.Boolean

    RaiseExceptionCatched(Object, Exception)

    Raises the ExceptionCatched event. If caching exceptions has been disabled by a SuspendCatchExceptions() call or if PassThroughExceptions has been set to True, the exception is rethrown.

    Declaration
    public static bool RaiseExceptionCatched(object sender, Exception ex)
    Parameters
    Type Name Description
    System.Object sender
    System.Exception ex

    A System.Exception that was cached.

    Returns
    Type Description
    System.Boolean

    ResumeCatchExceptions()

    Temporarily resumes caching exceptions.

    Declaration
    public static void ResumeCatchExceptions()

    ShouldCatchExceptions()

    Indicates whether exceptions should be cached or if they should bubble up. RaiseExceptionCatched(Object, ExceptionCatchedEventArgs) calls this method.

    Declaration
    public static bool ShouldCatchExceptions()
    Returns
    Type Description
    System.Boolean

    SuspendCatchExceptions()

    Temporarily suspends caching exceptions.

    Declaration
    public static void SuspendCatchExceptions()

    Events

    ExceptionCatched

    Occurs when an exception was cached within the framework and ExceptionManager was notified.

    Declaration
    public static event ExceptionCatchedEventHandler ExceptionCatched
    Event Type
    Type Description
    ExceptionCatchedEventHandler
    Back to top Generated by DocFX
    Copyright © 2001 - 2022 Syncfusion Inc. All Rights Reserved