rt/vm/src/main/java/org/apidesign/vm4brwsr/ClosureWrapper.java
changeset 1956 442c7f2d54ea
parent 1787 ea12a3bb4b33
     1.1 --- a/rt/vm/src/main/java/org/apidesign/vm4brwsr/ClosureWrapper.java	Tue Feb 24 11:12:53 2015 +0100
     1.2 +++ b/rt/vm/src/main/java/org/apidesign/vm4brwsr/ClosureWrapper.java	Thu Apr 28 06:09:26 2016 +0200
     1.3 @@ -19,6 +19,7 @@
     1.4  
     1.5  import com.google.javascript.jscomp.CommandLineRunner;
     1.6  import com.google.javascript.jscomp.SourceFile;
     1.7 +import java.io.ByteArrayOutputStream;
     1.8  import java.io.IOException;
     1.9  import java.io.OutputStream;
    1.10  import java.io.PrintStream;
    1.11 @@ -48,10 +49,10 @@
    1.12      private String externsCode;
    1.13  
    1.14      private ClosureWrapper(Appendable out,
    1.15 -                           String compilationLevel, Bck2Brwsr config) {
    1.16 +                           String compilationLevel, Bck2Brwsr config, PrintStream err) {
    1.17          super(
    1.18              generateArguments(compilationLevel),
    1.19 -            new PrintStream(new APS(out)), System.err
    1.20 +            new PrintStream(new APS(out)), err
    1.21          );
    1.22          this.config = config;
    1.23      }
    1.24 @@ -142,16 +143,16 @@
    1.25          ObfuscationLevel obfuscationLevel,
    1.26          Bck2Brwsr config
    1.27      ) throws IOException {
    1.28 -        final ClosureWrapper cw =
    1.29 -                new ClosureWrapper(output,
    1.30 -                                   (obfuscationLevel == ObfuscationLevel.FULL)
    1.31 -                                           ? "ADVANCED_OPTIMIZATIONS"
    1.32 -                                           : "SIMPLE_OPTIMIZATIONS",
    1.33 -                                   config);
    1.34 +        ByteArrayOutputStream out = new ByteArrayOutputStream();
    1.35 +        PrintStream err = new PrintStream(out);
    1.36 +        final ClosureWrapper cw = new ClosureWrapper(output,
    1.37 +            (obfuscationLevel == ObfuscationLevel.FULL) ? "ADVANCED_OPTIMIZATIONS" : "SIMPLE_OPTIMIZATIONS",
    1.38 +            config, err
    1.39 +        );
    1.40          try {
    1.41              return cw.doRun();
    1.42          } catch (FlagUsageException ex) {
    1.43 -            throw new IOException(ex);
    1.44 +            throw new IOException(out.toString(), ex);
    1.45          }
    1.46      }
    1.47