Skip to content

Commit 9545349

Browse files
committed
Show full stacktrace on eval error
Currently only first part of stacktrace is displayed, which is usually something like 'Syntax error reading source at' without displaying root cause. Nested stacktraces (for re-thrown exceptions) contain critical information so they should be displayed as well. Apparently there is a service 'stacktrace' object with a single field called 'status' and value [done]. This needs to be filtered as it has no data to display.
1 parent 9577047 commit 9545349

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

src/clojureEval.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -177,26 +177,32 @@ function handleError(outputChannel: vscode.OutputChannel, selection: vscode.Sele
177177

178178
return nreplClient.stacktrace(session)
179179
.then(stacktraceObjs => {
180-
const stacktraceObj = stacktraceObjs[0];
180+
stacktraceObjs.forEach((stacktraceObj: any) => {
181+
if (stacktraceObj.status && stacktraceObj.status.indexOf("done") >= 0) {
182+
return;
183+
}
181184

182-
let errLine = stacktraceObj.line !== undefined ? stacktraceObj.line - 1 : 0;
183-
let errChar = stacktraceObj.column !== undefined ? stacktraceObj.column - 1 : 0;
185+
let errLine = stacktraceObj.line !== undefined ? stacktraceObj.line - 1 : 0;
186+
let errChar = stacktraceObj.column !== undefined ? stacktraceObj.column - 1 : 0;
184187

185-
if (!selection.isEmpty) {
186-
errLine += selection.start.line;
187-
errChar += selection.start.character;
188-
}
188+
if (!selection.isEmpty) {
189+
errLine += selection.start.line;
190+
errChar += selection.start.character;
191+
}
189192

190-
outputChannel.appendLine(`${stacktraceObj.class} ${stacktraceObj.message}`);
191-
outputChannel.appendLine(` at ${stacktraceObj.file}:${errLine}:${errChar}`);
193+
outputChannel.appendLine(`${stacktraceObj.class} ${stacktraceObj.message}`);
194+
if (stacktraceObj.file) {
195+
outputChannel.appendLine(` at ${stacktraceObj.file}:${errLine}:${errChar}`);
196+
}
192197

193-
stacktraceObj.stacktrace.forEach((trace: any) => {
194-
if (trace.flags.indexOf('tooling') > -1)
195-
outputChannel.appendLine(` ${trace.class}.${trace.method} (${trace.file}:${trace.line})`);
196-
});
198+
stacktraceObj.stacktrace.forEach((trace: any) => {
199+
if (trace.flags.indexOf('tooling') > -1)
200+
outputChannel.appendLine(` ${trace.class}.${trace.method} (${trace.file}:${trace.line})`);
201+
});
197202

198-
outputChannel.show(true);
199-
nreplClient.close(session);
203+
outputChannel.show(true);
204+
nreplClient.close(session);
205+
});
200206
});
201207
}
202208

0 commit comments

Comments
 (0)