Author: sshafroi
Date: 2008-04-01 15:11:14 +0200 (Tue, 01 Apr 2008)
New Revision: 6324

Modified:
   branches/2.16/mojo/src/main/java/no/sesat/mojo/modes/Builder.java
Log:
Make it more robust.



Modified: branches/2.16/mojo/src/main/java/no/sesat/mojo/modes/Builder.java
===================================================================
--- branches/2.16/mojo/src/main/java/no/sesat/mojo/modes/Builder.java   
2008-04-01 10:42:22 UTC (rev 6323)
+++ branches/2.16/mojo/src/main/java/no/sesat/mojo/modes/Builder.java   
2008-04-01 13:11:14 UTC (rev 6324)
@@ -48,36 +48,40 @@
         // hack to suppress javadoc's warnings.
         final PrintStream out = System.out;
         final PrintStream err = System.err;
-        System.setOut(new PrintStream(new ByteArrayOutputStream()));
-        System.setErr(new PrintStream(new ByteArrayOutputStream()));
+        try {
+            System.setOut(new PrintStream(new ByteArrayOutputStream()));
+            System.setErr(new PrintStream(new ByteArrayOutputStream()));
 
-        final Context context = new Context();
-        Messager.preRegister(context, "Builder");
-        final JavadocTool comp = JavadocTool.make0(context);
+            final Context context = new Context();
+            Messager.preRegister(context, "Builder");
+            final JavadocTool comp = JavadocTool.make0(context);
 
-        final ListBuffer<String> subPackages = new ListBuffer<String>();
-        subPackages.append("no");
-        final ListBuffer<String> xcludePackages = new ListBuffer<String>();
-        final ListBuffer<String> javaNames = new ListBuffer<String>();
-        final ListBuffer<String[]> options = new ListBuffer<String[]>();
+            final ListBuffer<String> subPackages = new ListBuffer<String>();
+            subPackages.append("no");
+            final ListBuffer<String> xcludePackages = new ListBuffer<String>();
+            final ListBuffer<String> javaNames = new ListBuffer<String>();
+            final ListBuffer<String[]> options = new ListBuffer<String[]>();
 
-        final Options compOpts = Options.instance(context);
-        compOpts.put("-classpath", classpath);
-
-        RootDocImpl root = null;
-        try {
-            root = comp.getRootDocImpl("", "", new ModifierFilter(PUBLIC | 
PROTECTED), javaNames.toList(), options
-                    .toList(), false, subPackages.toList(), 
xcludePackages.toList(), false, false, false);
-        } catch (IOException e) {
-            e.printStackTrace();
+            final Options compOpts = Options.instance(context);
+            compOpts.put("-classpath", classpath);
+            RootDocImpl root = null;
+            try {
+                root = comp.getRootDocImpl("", "", new ModifierFilter(PUBLIC | 
PROTECTED), javaNames.toList(), options
+                        .toList(), false, subPackages.toList(), 
xcludePackages.toList(), false, false, false);
+            } catch (IOException e) {
+                e.printStackTrace(err);
+                return;
+            }
+            if (root != null) {
+                start(root);
+            }
+        } catch (Throwable e) {
+            // e.printStackTrace(out);
+            out.print("Generating schema files failed due to error: " + 
e.getMessage());
+        } finally {
+            System.setOut(out);
+            System.setErr(err);
         }
-
-        System.setOut(out);
-        System.setErr(err);
-
-        if (root != null) {
-            start(root);
-        }
     }
 
     /**

_______________________________________________
Kernel-commits mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-commits

Reply via email to