From 4ad45bf1ecb64702abb2124024dc358a9b373d36 Mon Sep 17 00:00:00 2001 From: "norris%netscape.com" Date: Fri, 5 Nov 1999 21:48:05 +0000 Subject: [PATCH] Remove JSuncaughtExceptionLine, use an error reporter to report line number info instead. --- .../tools/resources/Messages.properties | 3 --- .../mozilla/javascript/tools/shell/Main.java | 27 +++++++++++-------- .../tools/resources/Messages.properties | 3 --- .../mozilla/javascript/tools/shell/Main.java | 27 +++++++++++-------- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/js/rhino/org/mozilla/javascript/tools/resources/Messages.properties b/js/rhino/org/mozilla/javascript/tools/resources/Messages.properties index ffcc3d3ee544..777cadacf95f 100644 --- a/js/rhino/org/mozilla/javascript/tools/resources/Messages.properties +++ b/js/rhino/org/mozilla/javascript/tools/resources/Messages.properties @@ -89,9 +89,6 @@ msg.format3 =\ msg.uncaughtJSException =\ uncaught JavaScript exception: {0} -msg.uncaughtJSExceptionLine =\ - uncaught JavaScript exception ("{0}", line {1}): {2} - msg.jsc.usage =\ Didn''t understand "{0}". \n\ Valid arguments are: \n\ diff --git a/js/rhino/org/mozilla/javascript/tools/shell/Main.java b/js/rhino/org/mozilla/javascript/tools/shell/Main.java index 0cbf55f411ef..efaaa0df8779 100644 --- a/js/rhino/org/mozilla/javascript/tools/shell/Main.java +++ b/js/rhino/org/mozilla/javascript/tools/shell/Main.java @@ -245,6 +245,9 @@ public class Main { public static void processSource(Context cx, String filename) { SourceTextManager stm = cx.getSourceTextManager(); if (filename == null || filename.equals("-")) { + // Use the interpreter for interactive input + cx.setOptimizationLevel(-1); + BufferedReader in = new BufferedReader (new InputStreamReader(Main.in)); if(null != stm) @@ -292,9 +295,14 @@ public class Main { // Already printed message, so just fall through. } catch (EcmaError ee) { - Context.reportError(ToolErrorReporter.getMessage( - "msg.uncaughtJSException", - ee.toString())); + String msg = ToolErrorReporter.getMessage( + "msg.uncaughtJSException", ee.toString()); + if (ee.getSourceName() != null) { + Context.reportError(msg, ee.getSourceName(), + ee.getLineNumber(), null, 0); + } else { + Context.reportError(msg); + } } catch (JavaScriptException jse) { // Need to propagate ThreadDeath exceptions. @@ -360,16 +368,13 @@ public class Main { we.printStackTrace(); } catch (EcmaError ee) { + String msg = ToolErrorReporter.getMessage( + "msg.uncaughtJSException", ee.toString()); if (ee.getSourceName() != null) { - Object[] args = { ee.getSourceName(), - new Integer(ee.getLineNumber()), - ee.toString() }; - Context.reportError(ToolErrorReporter.getMessage( - "msg.uncaughtJSExceptionLine", args)); + Context.reportError(msg, ee.getSourceName(), + ee.getLineNumber(), null, 0); } else { - Context.reportError(ToolErrorReporter.getMessage( - "msg.uncaughtJSException", - ee.toString())); + Context.reportError(msg); } } catch (EvaluatorException ee) { diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties b/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties index ffcc3d3ee544..777cadacf95f 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/resources/Messages.properties @@ -89,9 +89,6 @@ msg.format3 =\ msg.uncaughtJSException =\ uncaught JavaScript exception: {0} -msg.uncaughtJSExceptionLine =\ - uncaught JavaScript exception ("{0}", line {1}): {2} - msg.jsc.usage =\ Didn''t understand "{0}". \n\ Valid arguments are: \n\ diff --git a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java index 0cbf55f411ef..efaaa0df8779 100644 --- a/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java +++ b/js/rhino/toolsrc/org/mozilla/javascript/tools/shell/Main.java @@ -245,6 +245,9 @@ public class Main { public static void processSource(Context cx, String filename) { SourceTextManager stm = cx.getSourceTextManager(); if (filename == null || filename.equals("-")) { + // Use the interpreter for interactive input + cx.setOptimizationLevel(-1); + BufferedReader in = new BufferedReader (new InputStreamReader(Main.in)); if(null != stm) @@ -292,9 +295,14 @@ public class Main { // Already printed message, so just fall through. } catch (EcmaError ee) { - Context.reportError(ToolErrorReporter.getMessage( - "msg.uncaughtJSException", - ee.toString())); + String msg = ToolErrorReporter.getMessage( + "msg.uncaughtJSException", ee.toString()); + if (ee.getSourceName() != null) { + Context.reportError(msg, ee.getSourceName(), + ee.getLineNumber(), null, 0); + } else { + Context.reportError(msg); + } } catch (JavaScriptException jse) { // Need to propagate ThreadDeath exceptions. @@ -360,16 +368,13 @@ public class Main { we.printStackTrace(); } catch (EcmaError ee) { + String msg = ToolErrorReporter.getMessage( + "msg.uncaughtJSException", ee.toString()); if (ee.getSourceName() != null) { - Object[] args = { ee.getSourceName(), - new Integer(ee.getLineNumber()), - ee.toString() }; - Context.reportError(ToolErrorReporter.getMessage( - "msg.uncaughtJSExceptionLine", args)); + Context.reportError(msg, ee.getSourceName(), + ee.getLineNumber(), null, 0); } else { - Context.reportError(ToolErrorReporter.getMessage( - "msg.uncaughtJSException", - ee.toString())); + Context.reportError(msg); } } catch (EvaluatorException ee) {