langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java
changeset 40769 e57f1a5c9346
parent 39807 ba0ff343d241
child 41514 a75c2b869d8d
--- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java	Mon Aug 29 15:53:03 2016 +0200
+++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/Eval.java	Thu Sep 01 12:13:13 2016 -0700
@@ -555,9 +555,11 @@
                             : "";
                 } catch (ResolutionException ex) {
                     DeclarationSnippet sn = (DeclarationSnippet) state.maps.getSnippetDeadOrAlive(ex.id());
-                    exception = new UnresolvedReferenceException(sn, ex.getStackTrace());
+                    exception = new UnresolvedReferenceException(sn, translateExceptionStack(ex));
                 } catch (UserException ex) {
-                    exception = translateExecutionException(ex);
+                    exception = new EvalException(translateExceptionMessage(ex),
+                            ex.causeExceptionClass(),
+                            translateExceptionStack(ex));
                 } catch (RunException ex) {
                     // StopException - no-op
                 } catch (InternalException ex) {
@@ -732,7 +734,7 @@
         }
     }
 
-    private EvalException translateExecutionException(UserException ex) {
+    private StackTraceElement[] translateExceptionStack(Exception ex) {
         StackTraceElement[] raw = ex.getStackTrace();
         int last = raw.length;
         do {
@@ -759,11 +761,14 @@
                 elems[i] = r;
             }
         }
+        return elems;
+    }
+
+    private String translateExceptionMessage(Exception ex) {
         String msg = ex.getMessage();
-        if (msg.equals("<none>")) {
-            msg = null;
-        }
-        return new EvalException(msg, ex.causeExceptionClass(), elems);
+        return msg.equals("<none>")
+                ? null
+                : msg;
     }
 
     private boolean isWrap(StackTraceElement ste) {