ObjectReference (@Nullable EvaluationContextImpl evaluationContext, EvaluateException ex, boolean printToConsole) { final ObjectReference exceptionObj = ex.getExceptionFromTargetVM(); if (exceptionObj != null && evaluationContext != null) { try { Value trace = invokeExceptionGetStackTrace(exceptionObj, evaluationContext); // print to console as well if (printToConsole && trace instanceof ArrayReference traceArray) { DebugProcessImpl process = evaluationContext.getDebugProcess(); process.printToConsole(DebuggerUtils.getValueAsString(evaluationContext, exceptionObj) + "\n"); for (Value stackElement : traceArray.getValues()) { process.printToConsole("\tat " + DebuggerUtils.getValueAsString(evaluationContext, stackElement) + "\n"); } } } catch (EvaluateException ignored) { } catch (Throwable e) { LOG.info(e); // catch all exceptions to ensure the method returns gracefully } } return exceptionObj; }