diff --git a/src/kernels/execution/cellExecutionMessageHandler.ts b/src/kernels/execution/cellExecutionMessageHandler.ts index 88784a659d2..04f746a98f7 100644 --- a/src/kernels/execution/cellExecutionMessageHandler.ts +++ b/src/kernels/execution/cellExecutionMessageHandler.ts @@ -1074,14 +1074,16 @@ export class CellExecutionMessageHandler implements IDisposable { traceback }; - const cellExecution = CellExecutionCreator.get(this.cell); - if (cellExecution && msg.content.ename !== 'KeyboardInterrupt') { - cellExecution.errorInfo = { - message: `${msg.content.ename}: ${msg.content.evalue}`, - location: this.failureDiagostics.parseStackTrace(traceback, this.cell).range, - uri: this.cell.document.uri, - stack: msg.content.traceback.join('\n') - }; + if (this.cell.notebook.notebookType !== 'interactive') { + const cellExecution = CellExecutionCreator.get(this.cell); + if (cellExecution && msg.content.ename !== 'KeyboardInterrupt') { + cellExecution.errorInfo = { + message: `${msg.content.ename}: ${msg.content.evalue}`, + location: this.failureDiagostics.parseStackTrace(msg.content.traceback, this.cell).range, + uri: this.cell.document.uri, + stack: msg.content.traceback.join('\n') + }; + } } this.addToCellData(output, msg); diff --git a/src/kernels/execution/cellFailureDiagnostics.ts b/src/kernels/execution/cellFailureDiagnostics.ts index 343397018b8..c0e5ed1c768 100644 --- a/src/kernels/execution/cellFailureDiagnostics.ts +++ b/src/kernels/execution/cellFailureDiagnostics.ts @@ -83,7 +83,7 @@ export class CellFailureDiagnostics { } let range: Range | undefined = undefined; - if (lineNumber) { + if (lineNumber && lineNumber > 0 && lineNumber <= cell.document.lineCount) { const line = cell.document.lineAt(lineNumber - 1); const end = line.text.split('#')[0].trimEnd().length;