HandleExceptions() 공개 정적인 메소드

Runs the given Action and handles all non-critical exceptions by showing an error dialog to the user. If the exception is critical, as determiend by ErrorHandler.IsCriticalException(Exception) then it is re-thrown as this could be that the process is not in a good state to continue executing.
public static HandleExceptions ( System.Action action ) : void
action System.Action
리턴 void
예제 #1
0
        /// <summary>
        /// Shows the tool window
        /// </summary>
        /// <returns>The tool window object if it is found.</returns>
        public static TToolWindow ShowToolWindow <TToolWindow>() where TToolWindow : ToolWindowPane
        {
            if (GoogleCloudExtensionPackage.Instance == null)
            {
                Debug.WriteLine("GoogleCloudExtensionPackage.Instance is null, unexpected error");
                return(null);
            }

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            ToolWindowPane window = GoogleCloudExtensionPackage.Instance.FindToolWindow(typeof(TToolWindow), 0, true);

            ErrorHandlerUtils.HandleExceptions(() =>
            {
                if (window?.Frame == null)
                {
                    throw new NotSupportedException("Failed to create the tool window");
                }

                IVsWindowFrame windowFrame = (IVsWindowFrame)window.Frame;
                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(windowFrame.Show());
            });
            return(window as TToolWindow);
        }
예제 #2
0
 /// <summary>
 /// Invokes the action handling all of the exceptions that escape the action.
 /// </summary>
 public void Invoke()
 {
     ErrorHandlerUtils.HandleExceptions(() => _action());
 }
예제 #3
0
 /// <summary>
 /// Safely executes the supplied action.
 /// </summary>
 public override void Execute(object _) => ErrorHandlerUtils.HandleExceptions(_action);