ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant Main.java
Date Mon, 16 Oct 2000 09:21:36 GMT
bodewig     00/10/16 02:21:34

  Modified:    src/main/org/apache/tools/ant Main.java
  Log:
  Don't print the message of a thrown BuildException to stderr twice.
  
  Submitted by:	Diane Holt <holtdl@yahoo.com>,
                  Nico Seessle <Nico.Seessle@epost.de>
  
  Revision  Changes    Path
  1.22      +26 -6     jakarta-ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Main.java	2000/09/24 09:00:07	1.21
  +++ Main.java	2000/10/16 09:21:22	1.22
  @@ -119,6 +119,16 @@
       private boolean projectHelp = false;
   
       /**
  +     * Prints the message of the Throwable if it's not null.
  +     */
  +    private static void printMessage(Throwable t) {
  +        String message = t.getMessage();
  +        if (message != null) {
  +            System.err.println(message);
  +        }
  +    }
  +
  +    /**
        * Command line entry point. This method kicks off the building
        * of a project object and executes a build using either a given
        * target or the default target.
  @@ -126,15 +136,25 @@
        * @param args Command line args.
        */
       public static void main(String[] args) {
  +        Main m = null;
  +
           try {
  -            new Main(args).runBuild();
  -            System.exit(0);
  +            m = new Main(args);
  +        } catch(Throwable exc) {
  +            printMessage(exc);
  +            System.exit(1);
           }
  -        catch(Throwable exc) {
  -            String message = exc.getMessage();
  -            if (message != null) {
  -                System.err.println(message);
  +
  +        try {
  +            m.runBuild();
  +            System.exit(0);
  +        } catch (BuildException be) {
  +            if (m.err != System.err) {
  +                printMessage(be);
               }
  +            System.exit(1);
  +        } catch(Throwable exc) {
  +            printMessage(exc);
               System.exit(1);
           }
       }
  
  
  

Mime
View raw message