diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java index 29b6af3ec56889fefb10ab75f4bebf424b7020e8..a7860653075d8897e8378464797924b158d3d477 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RDeparse.java @@ -415,9 +415,7 @@ public class RDeparse { } } } catch (AccessDeniedException | FileAlreadyExistsException | IllegalArgumentException e) { - fixupSourcesTextInternal(); - } catch (IOException e) { - RInternalError.reportError(e); + // do not report because these exceptions are legitimate fixupSourcesTextInternal(); } catch (Throwable e) { RInternalError.reportError(e); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java index 7ba302c0e9315aa49ec2d5c44481e86ad9d45cde..fc61fb2ff916c2bc36d755751af3ee12283e5161 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RInternalError.java @@ -45,6 +45,8 @@ import com.oracle.truffle.r.runtime.context.RContext; */ public final class RInternalError extends Error implements TruffleException { + private static final String FASTR_ERRORS_LOG = "fastr_errors.log"; + private static final long serialVersionUID = 80698622974155216L; private static boolean initializing = false; @@ -154,20 +156,24 @@ public final class RInternalError extends Error implements TruffleException { @TruffleBoundary public static void reportErrorAndConsoleLog(Throwable throwable, int contextId) { - reportError(throwable, contextId); + reportErrorDefault(throwable, contextId); } @TruffleBoundary public static void reportError(Throwable t) { - String message = t instanceof RInternalError && t.getMessage() != null && !t.getMessage().isEmpty() ? t.getMessage() : "internal error: " + t.getClass().getSimpleName(); - reportError(message, t, 0); + reportErrorDefault(t, 0); + } + + @TruffleBoundary + private static void reportErrorDefault(Throwable t, int contextId) { + String errMsg = t instanceof RInternalError && t.getMessage() != null && !t.getMessage().isEmpty() ? t.getMessage() : t.getClass().getSimpleName(); + reportError(errMsg, t, contextId); } - private static void reportError(String message, Throwable throwable, int contextId) { + private static void reportError(String errMsg, Throwable throwable, int contextId) { try { Throwable t = throwable; if (FastROptions.PrintErrorStacktracesToFile.getBooleanValue() || FastROptions.PrintErrorStacktraces.getBooleanValue()) { - ByteArrayOutputStream out = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(out)); String verboseStackTrace; @@ -185,9 +191,15 @@ public final class RInternalError extends Error implements TruffleException { System.err.println(out.toString()); System.err.println(verboseStackTrace); } + + String message = "An internal error occurred: \"" + errMsg + "\"\nPlease report an issue including the commands"; + if (FastROptions.PrintErrorStacktracesToFile.getBooleanValue()) { + message += " and the error log file '" + getLogFileName(contextId) + "'."; + } else { + message += "."; + } if (FastROptions.PrintErrorStacktracesToFile.getBooleanValue()) { - String suffix = contextId == 0 ? "" : "-" + Integer.toString(contextId); - Path logfile = Utils.getLogPath("fastr_errors.log" + suffix); + Path logfile = Utils.getLogPath(getLogFileName(contextId)); try (BufferedWriter writer = Files.newBufferedWriter(logfile, StandardCharsets.UTF_8, StandardOpenOption.APPEND, StandardOpenOption.CREATE)) { writer.append(new Date().toString()).append('\n'); @@ -196,7 +208,7 @@ public final class RInternalError extends Error implements TruffleException { } catch (IOException e) { e.printStackTrace(); } - System.err.println(message + " (see fastr_errors.log" + suffix + ")"); + System.err.println(message); if (RContext.isEmbedded()) { RSuicide.rSuicide("FastR internal error"); } @@ -211,6 +223,10 @@ public final class RInternalError extends Error implements TruffleException { } } + private static String getLogFileName(int contextId) { + return contextId == 0 ? FASTR_ERRORS_LOG : FASTR_ERRORS_LOG + "-" + Integer.toString(contextId); + } + @Override public Node getLocation() { return null;