This is an automated email from the ASF dual-hosted git repository. lkishalmi pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new bcdd20f Provide shorter evaluation error, without the unneccessary prefix. bcdd20f is described below commit bcdd20ffaa5dc5384634dffb3c9cc26f3c97cb69 Author: Martin Entlicher <martin.entlic...@oracle.com> AuthorDate: Mon Nov 9 16:33:51 2020 +0100 Provide shorter evaluation error, without the unneccessary prefix. --- .../modules/debugger/jpda/truffle/access/TruffleEval.java | 8 ++++++++ .../modules/debugger/jpda/expr/InvocationExceptionTranslated.java | 4 ++++ .../modules/java/lsp/server/debugging/NbProtocolServer.java | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/access/TruffleEval.java b/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/access/TruffleEval.java index 08c0e9c..80b3ae9 100644 --- a/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/access/TruffleEval.java +++ b/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/access/TruffleEval.java @@ -26,6 +26,7 @@ import org.netbeans.api.debugger.jpda.JPDADebugger; import org.netbeans.api.debugger.jpda.JPDAThread; import org.netbeans.api.debugger.jpda.ObjectVariable; import org.netbeans.api.debugger.jpda.Variable; +import org.netbeans.modules.debugger.jpda.expr.InvocationExceptionTranslated; import org.netbeans.modules.debugger.jpda.truffle.TruffleDebugManager; import org.openide.util.Exceptions; import org.openide.util.NbBundle; @@ -58,6 +59,13 @@ public class TruffleEval { new Variable[] { stackFrameInstance, mirrorExpression }); return valueVar; + } catch (InvalidExpressionException ex) { + Throwable targetException = ex.getTargetException(); + if (targetException instanceof InvocationExceptionTranslated) { + // We do not want to prepend Java exception message: + ((InvocationExceptionTranslated) targetException).resetInvocationMessage(); + } + throw ex; } catch (InvalidObjectException | NoSuchMethodException ex) { try { return debugger.createMirrorVar(ex.getLocalizedMessage()); diff --git a/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/InvocationExceptionTranslated.java b/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/InvocationExceptionTranslated.java index d0f824d..5610df2 100644 --- a/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/InvocationExceptionTranslated.java +++ b/java/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/InvocationExceptionTranslated.java @@ -95,6 +95,10 @@ public class InvocationExceptionTranslated extends Exception { this.createdAt = new Throwable().fillInStackTrace(); } + public void resetInvocationMessage() { + this.invocationMessage = null; + } + public void setPreferredThread(JPDAThreadImpl preferredThread) { this.preferredThread = preferredThread; } diff --git a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/NbProtocolServer.java b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/NbProtocolServer.java index bc6793b..cb2eff9 100644 --- a/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/NbProtocolServer.java +++ b/java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/NbProtocolServer.java @@ -379,13 +379,13 @@ public final class NbProtocolServer implements IDebugProtocolServer { String expression = args.getExpression(); if (StringUtils.isBlank(expression)) { throw ErrorUtilities.createResponseErrorException( - "Failed to evaluate. Reason: Empty expression cannot be evaluated.", + "Empty expression cannot be evaluated.", ResponseErrorCode.InvalidParams); } NbFrame stackFrame = (NbFrame) context.getThreadsProvider().getThreadObjects().getObject(args.getFrameId()); if (stackFrame == null) { throw ErrorUtilities.createResponseErrorException( - "Failed to evaluate. Reason: Unknown frame " + args.getFrameId(), + "Unknown frame " + args.getFrameId(), ResponseErrorCode.InvalidParams); } stackFrame.getDVFrame().makeCurrent(); // The evaluation is always performed with respect to the current frame @@ -397,7 +397,7 @@ public final class NbProtocolServer implements IDebugProtocolServer { variable = debugger.evaluate(expression); } catch (InvalidExpressionException ex) { throw ErrorUtilities.createResponseErrorException( - "Failed to evaluate. Reason: " + ex.getLocalizedMessage(), + ex.getLocalizedMessage(), ResponseErrorCode.ParseError); } EvaluateResponse response = new EvaluateResponse(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists