MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / translateCellErrorOutput

Function translateCellErrorOutput

src/kernels/execution/helpers.ts:358–382  ·  view source on GitHub ↗
(output: NotebookCellOutput)

Source from the content-addressed store, hash-verified

356}
357
358export function translateCellErrorOutput(output: NotebookCellOutput): nbformat.IError {
359 // it should have at least one output item
360 const firstItem = output.items[0];
361 // Bug in VS Code.
362 if (!firstItem.data) {
363 return {
364 output_type: 'error',
365 ename: '',
366 evalue: '',
367 traceback: []
368 };
369 }
370 const originalError: undefined | nbformat.IError = output.metadata?.originalError;
371 const value: Error = JSON.parse(new TextDecoder().decode(firstItem.data));
372 return {
373 output_type: 'error',
374 ename: value.name,
375 evalue: value.message,
376 // VS Code needs an `Error` object which requires a `stack` property as a string.
377 // Its possible the format could change when converting from `traceback` to `string` and back again to `string`
378 // When .NET stores errors in output (with their .NET kernel),
379 // stack is empty, hence store the message instead of stack (so that somethign gets displayed in ipynb).
380 traceback: originalError?.traceback || splitMultilineString(value.stack || value.message || '')
381 };
382}
383const textDecoder = new TextDecoder();
384const textMimeTypes = ['text/plain', 'text/markdown', CellOutputMimeTypes.stderr, CellOutputMimeTypes.stdout];
385function convertOutputMimeToJupyterOutput(mime: string, value: Uint8Array) {

Calls 3

splitMultilineStringFunction · 0.90
parseMethod · 0.65
decodeMethod · 0.65