commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From patri...@apache.org
Subject cvs commit: jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher ChildMain.java Launcher.java
Date Thu, 11 Jul 2002 23:41:57 GMT
patrickl    2002/07/11 16:41:57

  Modified:    daemon/src/java LauncherBootstrap.java
               daemon/src/java/org/apache/commons/launcher ChildMain.java
                        Launcher.java
  Log:
  Make non-verbose error messages verbose if there is no message to print.
  
  Revision  Changes    Path
  1.4       +14 -4     jakarta-commons-sandbox/daemon/src/java/LauncherBootstrap.java
  
  Index: LauncherBootstrap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/LauncherBootstrap.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LauncherBootstrap.java	11 Jul 2002 21:35:28 -0000	1.3
  +++ LauncherBootstrap.java	11 Jul 2002 23:41:57 -0000	1.4
  @@ -124,6 +124,11 @@
        */
       public final static String LAUNCHER_XML_FILE_NAME = "launcher.xml";
   
  +    /**
  +     * Cached Laucher class.
  +     */
  +    private static Class launcherClass = null;
  +
       //---------------------------------------------------------- Static Methods
   
       /**
  @@ -177,7 +182,7 @@
                   loader = new URLClassLoader(urls);
   
               // Load the LAUNCHER_MAIN_CLASS_NAME class
  -            Class launcherClass = loader.loadClass(LAUNCHER_MAIN_CLASS_NAME);
  +            launcherClass = loader.loadClass(LAUNCHER_MAIN_CLASS_NAME);
   
               // Get the LAUNCHER_MAIN_CLASS_NAME class' getLocalizedString()
               // method as we need it for printing the usage statement
  @@ -224,9 +229,14 @@
               startMethod.invoke(null, new Object[]{ startArgs, launchFile });
   
          } catch (Throwable t) {
  -            System.out.println(LauncherBootstrap.class.getName() + ":");
  -            t.printStackTrace();
  -            System.exit(1);
  +            String message = t.getMessage();
  +            try {
  +                Method errorMethod = launcherClass.getMethod("error", new Class[]{ Throwable.class
});
  +                errorMethod.invoke(null, new Object[]{ t });
  +            } catch (Exception e) {
  +                t.printStackTrace();
  +                System.exit(1);
  +            }
           }
   
           // Always exit cleanly
  
  
  
  1.3       +3 -2      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/ChildMain.java
  
  Index: ChildMain.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/ChildMain.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ChildMain.java	11 Jul 2002 21:35:28 -0000	1.2
  +++ ChildMain.java	11 Jul 2002 23:41:57 -0000	1.3
  @@ -175,8 +175,9 @@
                   System.exit(0);
               }
   
  -        } catch (Exception e) {
  -            Launcher.error(e, true);
  +        } catch (Throwable t) {
  +            Launcher.setVerbose(true);
  +            Launcher.error(t);
           }
   
       }
  
  
  
  1.4       +2 -4      jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher.java
  
  Index: Launcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/daemon/src/java/org/apache/commons/launcher/Launcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Launcher.java	11 Jul 2002 21:35:28 -0000	1.3
  +++ Launcher.java	11 Jul 2002 23:41:57 -0000	1.4
  @@ -530,15 +530,13 @@
        * Print a detailed error message and exit.
        *
        * @param message the exception whose stack trace is to be printed.
  -     * @param verbose if true print a stack trace of the excetion else print
  -     *  just the message
        */
  -    public static void error(Throwable t, boolean verbose) {
  +    public static void error(Throwable t) {
   
           String message = t.getMessage();
           if (!Launcher.verbose && message != null)
               Launcher.getLog().println(Launcher.getLocalizedString("error") + ": " + message);
  -        if (Launcher.verbose)
  +        else
               t.printStackTrace(Launcher.getLog());
           System.exit(1);
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message