This class implements an event handler for the exceptions that escape the given Action.
Exemplo n.º 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create empty solution at the <paramref name="localPath"/>
        /// </summary>
        /// <param name="localPath">Create the solution at the path.</param>
        /// <param name="name">The solution name.</param>
        public static void CreateEmptySolution(string localPath, string name)
        {
            localPath.ThrowIfNullOrEmpty(nameof(localPath));
            var dte = Package.GetGlobalService(typeof(DTE)) as DTE2;

            try
            {
                dte.Solution.Create(localPath, name);
                dte.Solution.Close(false);
            }
            catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex))
            {
            }
        }
        /// <summary>
        /// Create empty solution at the <paramref name="localPath"/>
        /// </summary>
        /// <param name="localPath">Create the solution at the path.</param>
        /// <param name="name">The solution name.</param>
        public void CreateEmptySolution(string localPath, string name)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            localPath.ThrowIfNullOrEmpty(nameof(localPath));
            DTE2 dte = GoogleCloudExtensionPackage.Instance.Dte;

            try
            {
                dte.Solution.Create(localPath, name);
                dte.Solution.Close(false);
            }
            catch (Exception ex) when(!ErrorHandlerUtils.IsCriticalException(ex))
            {
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Invokes the action handling all of the exceptions that escape the action.
 /// </summary>
 public void Invoke()
 {
     ErrorHandlerUtils.HandleExceptions(() => _action());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Safely executes the supplied action.
 /// </summary>
 public override void Execute(object _) => ErrorHandlerUtils.HandleExceptions(_action);
 /// <summary>
 /// Invokes the task handling all of the exceptions that escape the task.
 /// </summary>
 public void Invoke()
 {
     ErrorHandlerUtils.HandleAsyncExceptions(_task);
 }