The error reporting in CommandProcessor is improved. BLD200211250100
authormentlicher@netbeans.org
Fri, 22 Nov 2002 18:31:57 +0000
changeset 283244940c275fed
parent 2831 86724e20281e
child 2833 5513ee143fd8
The error reporting in CommandProcessor is improved.
When creation of a customizer or command execution throws some
exception, the user is properly notified about it.
Two null pointer exceptions are fixed in ExecuteCommand and UserCommandSupport.
This is a fix of issue #28508.
vcscore/src/org/netbeans/modules/vcscore/cmdline/ExecuteCommand.java
vcscore/src/org/netbeans/modules/vcscore/cmdline/UserCommandSupport.java
vcscore/src/org/netbeans/modules/vcscore/commands/CommandProcessor.java
     1.1 --- a/vcscore/src/org/netbeans/modules/vcscore/cmdline/ExecuteCommand.java	Fri Nov 22 17:06:56 2002 +0000
     1.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/cmdline/ExecuteCommand.java	Fri Nov 22 18:31:57 2002 +0000
     1.3 @@ -354,7 +354,7 @@
     1.4      public String preprocessCommand(VcsCommand vc, Hashtable vars, String exec) {
     1.5          this.preferredExec = exec;
     1.6          fileSystem.getVarValueAdjustment().adjustVarValues(vars);
     1.7 -        if (exec.indexOf(Variables.TEMPORARY_FILE) >= 0) {
     1.8 +        if (exec != null && exec.indexOf(Variables.TEMPORARY_FILE) >= 0) {
     1.9              try {
    1.10                  File tempFile = File.createTempFile("VCS", "tmp");
    1.11                  tempFile.deleteOnExit();
     2.1 --- a/vcscore/src/org/netbeans/modules/vcscore/cmdline/UserCommandSupport.java	Fri Nov 22 17:06:56 2002 +0000
     2.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/cmdline/UserCommandSupport.java	Fri Nov 22 18:31:57 2002 +0000
     2.3 @@ -457,7 +457,7 @@
     2.4                  customizer = (UserCommandCustomizer) finalCustomizer;
     2.5              } else customizer = null;
     2.6          }
     2.7 -        cmd.setPreferredExec(newExec);
     2.8 +        if (newExec != null) cmd.setPreferredExec(newExec);
     2.9          cmd.setAdditionalVariables(vars);
    2.10          //System.out.println("subFiles = "+subFiles+", files = "+files+", MODULE = "+cmd.getAdditionalVariables().get("MODULE")+", DIR = "+cmd.getAdditionalVariables().get("DIR"));
    2.11          if (finalCustomizer == null && files != null) {
    2.12 @@ -517,7 +517,7 @@
    2.13                                                 cmdCanRunOnMultipleFiles,
    2.14                                                 cmdCanRunOnMultipleFilesInFolder);
    2.15              String newExec = CommandCustomizationSupport.preCustomize(fileSystem, nextCmd.getVcsCommand(), newVars);
    2.16 -            nextCmd.setPreferredExec(newExec);
    2.17 +            if (newExec != null) nextCmd.setPreferredExec(newExec);
    2.18              nextCmd.setAdditionalVariables(newVars);
    2.19              return nextCustomizedCommand;
    2.20          }
     3.1 --- a/vcscore/src/org/netbeans/modules/vcscore/commands/CommandProcessor.java	Fri Nov 22 17:06:56 2002 +0000
     3.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/commands/CommandProcessor.java	Fri Nov 22 18:31:57 2002 +0000
     3.3 @@ -27,6 +27,7 @@
     3.4  import java.beans.PropertyChangeEvent;
     3.5  import java.util.*;
     3.6  
     3.7 +import org.openide.ErrorManager;
     3.8  import org.openide.TopManager;
     3.9  import org.openide.DialogDescriptor;
    3.10  import org.openide.NotifyDescriptor;
    3.11 @@ -231,6 +232,7 @@
    3.12                  try {
    3.13                      status = showCustomizer(cmd);
    3.14                  } catch (IntrospectionException iex) {
    3.15 +                    ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, iex);
    3.16                      status = false;
    3.17                  } finally {
    3.18                      for(Iterator it = commandListeners.iterator(); it.hasNext(); ) {
    3.19 @@ -283,7 +285,15 @@
    3.20              }
    3.21          // HACK with the PrivilegedAction to get a custom customizer
    3.22          } else if (cmd instanceof java.security.PrivilegedAction) {
    3.23 -            Object customizer = ((java.security.PrivilegedAction) cmd).run();
    3.24 +            Object customizer;
    3.25 +            try {
    3.26 +                customizer = ((java.security.PrivilegedAction) cmd).run();
    3.27 +            } catch (ThreadDeath td) {
    3.28 +                throw td;
    3.29 +            } catch (Throwable th) {
    3.30 +                ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, th);
    3.31 +                customizer = null;
    3.32 +            }
    3.33              //System.out.println("customizer of command "+cmd+" = "+customizer);
    3.34              //System.out.println("customizer instanceof Component = "+(customizer instanceof Component));
    3.35              if (customizer instanceof UserCancelException) {
    3.36 @@ -725,11 +735,11 @@
    3.37                  try {
    3.38                      cw.run();
    3.39                  } catch (RuntimeException rexc) {
    3.40 -                    TopManager.getDefault().notifyException(rexc);
    3.41 +                    ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, rexc);
    3.42                  } catch (ThreadDeath tderr) {
    3.43                      err = tderr;
    3.44                  } catch (Throwable t) {
    3.45 -                    TopManager.getDefault().notifyException(t);
    3.46 +                    ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, t);
    3.47                  }
    3.48                  commandDone(cw);
    3.49                  if (err != null) throw err;