Add Option to Halt Notebook when Error Occurs in SQL Kernel (#7884)

* Add Option to Halt Nb when Error Occurs

* PR comments
This commit is contained in:
Chris LaFreniere
2019-10-22 18:19:36 -07:00
committed by GitHub
parent 2ca5d18855
commit 4c24043cc8
2 changed files with 20 additions and 1 deletions

View File

@@ -160,6 +160,19 @@ configurationRegistry.registerConfiguration({
}
});
configurationRegistry.registerConfiguration({
'id': 'notebook',
'title': 'Notebook',
'type': 'object',
'properties': {
'notebook.sqlStopOnError': {
'type': 'boolean',
'default': true,
'description': localize('notebook.sqlStopOnError', "SQL kernel: stop Notebook execution when error occurs in a cell.")
}
}
});
registerAction({
id: 'workbench.books.action.focusBooksExplorer',
handler: async (accessor) => {

View File

@@ -30,6 +30,7 @@ export const sqlKernelError: string = localize("sqlKernelError", "SQL kernel err
export const MAX_ROWS = 5000;
export const NotebookConfigSectionName = 'notebook';
export const MaxTableRowsConfigName = 'maxTableRows';
export const SqlStopOnErrorConfigName = 'sqlStopOnError';
const languageMagics: ILanguageMagic[] = [{
language: 'Python',
@@ -379,6 +380,8 @@ export class SQLFuture extends Disposable implements FutureInternal {
private configuredMaxRows: number = MAX_ROWS;
private _outputAddedPromises: Promise<void>[] = [];
private _querySubsetResultMap: Map<number, QueryExecuteSubsetResult> = new Map<number, QueryExecuteSubsetResult>();
private _errorOccurred: boolean = false;
private _stopOnError: boolean = true;
constructor(
private _queryRunner: QueryRunner,
private _executionCount: number | undefined,
@@ -392,6 +395,7 @@ export class SQLFuture extends Disposable implements FutureInternal {
if (maxRows && maxRows > 0) {
this.configuredMaxRows = maxRows;
}
this._stopOnError = !!config[SqlStopOnErrorConfigName];
}
}
@@ -426,7 +430,7 @@ export class SQLFuture extends Disposable implements FutureInternal {
channel: 'shell',
type: 'execute_reply',
content: {
status: 'ok',
status: this._errorOccurred && this._stopOnError ? 'error' : 'ok',
execution_count: this._executionCount
},
header: undefined,
@@ -619,6 +623,8 @@ export class SQLFuture extends Disposable implements FutureInternal {
}
private convertToError(msg: IResultMessage | string): nb.IIOPubMessage {
this._errorOccurred = true;
if (msg) {
let msgData = typeof msg === 'string' ? msg : msg.message;
return {