Changeset 1385


Ignore:
Timestamp:
Oct 29, 2011, 11:15:57 PM (6 years ago)
Author:
stefan
Message:

some message boxed in case that ghc fails to compile

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/jlatexeditor/codehelper/ScriptingSupport.java

    r1382 r1385  
    154154
    155155        try {
    156           ProcessUtil.execAndWait(new String[]{"ghc", "--make", sourceName}, scriptDir);
    157           ProcessOutput result = ProcessUtil.execAndWait(new String[] {"./" + executableName}, scriptDir);
     156          ProcessOutput processOutput = ProcessUtil.execAndWait(new String[]{"ghc", "--make", sourceName}, scriptDir);
     157          if (processOutput.getReturnCode() > 0) {
     158            System.out.println(processOutput.getStderr());
     159            JOptionPane.showMessageDialog(null, processOutput.getStderr().trim(), "GHC error", JOptionPane.ERROR_MESSAGE);
     160            throw new IOException("GHC error");
     161          }
     162          ProcessOutput result = ProcessUtil.execAndWait(new String[] {"./" + executableName}, scriptDir);
    158163          output = result.getStdout();
    159164        } catch (IOException e1) {
     
    168173    } catch (IOException e) {
    169174      e.printStackTrace();
     175    } catch (InterruptedException ignored) {
    170176    }
    171177
  • trunk/src/util/ProcessOutput.java

    r1376 r1385  
    55 */
    66public class ProcessOutput {
    7   private String stdout;
     7  private int returnCode;
     8  private String stdout;
    89  private String stderr;
    910
    10   public ProcessOutput(String stdout, String stderr) {
    11     this.stdout = stdout;
     11  public ProcessOutput(int returnCode, String stdout, String stderr) {
     12    this.returnCode = returnCode;
     13    this.stdout = stdout;
    1214    this.stderr = stderr;
    1315  }
    1416
    15   public String getStdout() {
     17  public int getReturnCode() {
     18    return returnCode;
     19  }
     20
     21  public String getStdout() {
    1622    return stdout;
    1723  }
  • trunk/src/util/ProcessUtil.java

    r1376 r1385  
    4343  }
    4444
    45   public static ProcessOutput execAndWait(String command[], File dir) throws IOException {
     45  public static ProcessOutput execAndWait(String command[], File dir) throws IOException, InterruptedException {
    4646    Process process = exec(command, dir);
    4747
     
    5454    String stderr = errorReader.getError();
    5555
    56     return new ProcessOutput(stdout, stderr);
     56    int returnCode = process.waitFor();
     57
     58    return new ProcessOutput(returnCode, stdout, stderr);
    5759  }
    5860
Note: See TracChangeset for help on using the changeset viewer.