Skip to content

Commit

Permalink
Secondary fix for 9523 - Exception for loading should show in the oup…
Browse files Browse the repository at this point in the history
…tut (#10990)
  • Loading branch information
rchiodo authored Apr 6, 2020
1 parent 6c4a2fb commit c48b306
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
9 changes: 8 additions & 1 deletion src/datascience-ui/interactive-common/cellOutput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,14 @@ export class CellOutput extends React.Component<ICellOutputProps> {
if (this.isCodeCell() && this.hasOutput() && this.getCodeCell().outputs && !this.props.hideOutput) {
const trim = this.props.cellVM.cell.data.metadata.tags ? this.props.cellVM.cell.data.metadata.tags[0] : '';
// Render the outputs
return this.renderOutputs(this.getCodeCell().outputs, trim);
const outputs = this.renderOutputs(this.getCodeCell().outputs, trim);

// Render any UI side errors
if (this.props.cellVM.uiSideError) {
outputs.push(<div className="cell-output-uiSideError">{this.props.cellVM.uiSideError}</div>);
}

return outputs;
}
return [];
};
Expand Down
1 change: 1 addition & 0 deletions src/datascience-ui/interactive-common/mainState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface ICellViewModel {
hasBeenRun: boolean;
runDuringDebug?: boolean;
codeVersion?: number;
uiSideError?: string;
}

export type IMainState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,31 +224,16 @@ export namespace CommonEffects {
const newVMs = [...arg.prevState.cellVMs];
const current = arg.prevState.cellVMs[index];

const outputs = current.cell.data.outputs as nbformat.IOutput[];
const errorMessage = arg.payload.data.isOnline
? arg.payload.data.error.toString()
: getLocString(
'DataScience.loadClassFailedWithNoInternet',
'Error loading {0}:{1}. Internet connection required for loading 3rd party widgets.'
).format(arg.payload.data.moduleName, arg.payload.data.moduleVersion);
const error: nbformat.IError = {
output_type: 'error',
ename: 'Error',
evalue: errorMessage,
traceback: []
};

const newVM = Helpers.asCellViewModel({
newVMs[index] = Helpers.asCellViewModel({
...current,
cell: {
...current.cell,
data: {
...current.cell.data,
outputs: [...outputs, error]
}
}
uiSideError: errorMessage
});
newVMs[index] = newVM;

// Make sure to tell the extension so it can log telemetry.
postActionToExtension(arg, InteractiveWindowMessages.IPyWidgetLoadFailure, arg.payload.data);
Expand Down

0 comments on commit c48b306

Please sign in to comment.