Show an error in cell output when trying to load an unsupported output type. (#19693)

This commit is contained in:
Cory Rivera
2022-06-09 12:32:42 -07:00
committed by GitHub
parent fc7a27171d
commit a265224701
3 changed files with 22 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ import { nb } from 'azdata';
import { JSONObject, isPrimitive } from 'sql/workbench/services/notebook/common/jsonext';
import { nbformat } from 'sql/workbench/services/notebook/common/nbformat';
import { MimeModel } from 'sql/workbench/services/notebook/browser/outputs/mimemodel';
import * as nls from 'vs/nls';
/**
* A multiline string.
@@ -46,6 +47,8 @@ export function getData(output: nb.ICellOutput): JSONObject {
} else if (output.evalue) {
bundle['application/vnd.jupyter.stderr'] = output.ename ? `${output.ename}: ${output.evalue}` : `${output.evalue}`;
}
} else {
bundle['application/vnd.jupyter.stderr'] = nls.localize('notebookInvalidOutputTypeError', "Output type '{0}' not recognized.", output.output_type);
}
return convertBundle(bundle);
}

View File

@@ -67,6 +67,20 @@ suite('OutputProcessor functions', function (): void {
verifyGetDataForStreamOutput(output);
});
}
// unknown output types
test('Should report an error for unknown output types', () => {
const output = {
output_type: 'unknown',
data: {
'text/html': 'Test text'
},
metadata: {}
};
const result = op.getData(<any>output);
assert(result['application/vnd.jupyter.stderr'] !== undefined, 'Should set an error message after receiving unknown output type.');
assert(result['text/html'] === undefined, 'Should not add any data after receiving unknown output type.');
});
});
suite('getMetadata', function (): void {