Skip to content

Commit

Permalink
fixed issue that terminal error can not be printed sometimes because …
Browse files Browse the repository at this point in the history
…the error stream is closed by the handler before it is printed; as detected in #1895
  • Loading branch information
jurgenvinju committed Nov 29, 2023
1 parent 7687359 commit e17f90a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/org/rascalmpl/repl/BaseREPL.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,19 +363,21 @@ public void run() throws IOException {
// we are closing down, so do nothing, the finally clause will take care of it
}
catch (Throwable e) {
try (PrintWriter err = new PrintWriter(errorWriter, true)) {
PrintWriter err = new PrintWriter(errorWriter, true);

if (!err.checkError()) {
err.println("Unexpected (uncaught) exception, closing the REPL: ");
if (!err.checkError()) {
err.print(e.toString());
e.printStackTrace(err);
}
else {
System.err.print(e.toString());
e.printStackTrace();
}
err.flush();
err.print(e.toString());
e.printStackTrace(err);
}
errorWriter.flush();
else {
System.err.println("Unexpected (uncaught) exception, closing the REPL: ");
System.err.print(e.toString());
e.printStackTrace(System.err);
}

err.flush();

throw e;
}
finally {
Expand Down

0 comments on commit e17f90a

Please sign in to comment.