mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
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:
@@ -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({
|
registerAction({
|
||||||
id: 'workbench.books.action.focusBooksExplorer',
|
id: 'workbench.books.action.focusBooksExplorer',
|
||||||
handler: async (accessor) => {
|
handler: async (accessor) => {
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export const sqlKernelError: string = localize("sqlKernelError", "SQL kernel err
|
|||||||
export const MAX_ROWS = 5000;
|
export const MAX_ROWS = 5000;
|
||||||
export const NotebookConfigSectionName = 'notebook';
|
export const NotebookConfigSectionName = 'notebook';
|
||||||
export const MaxTableRowsConfigName = 'maxTableRows';
|
export const MaxTableRowsConfigName = 'maxTableRows';
|
||||||
|
export const SqlStopOnErrorConfigName = 'sqlStopOnError';
|
||||||
|
|
||||||
const languageMagics: ILanguageMagic[] = [{
|
const languageMagics: ILanguageMagic[] = [{
|
||||||
language: 'Python',
|
language: 'Python',
|
||||||
@@ -379,6 +380,8 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
|||||||
private configuredMaxRows: number = MAX_ROWS;
|
private configuredMaxRows: number = MAX_ROWS;
|
||||||
private _outputAddedPromises: Promise<void>[] = [];
|
private _outputAddedPromises: Promise<void>[] = [];
|
||||||
private _querySubsetResultMap: Map<number, QueryExecuteSubsetResult> = new Map<number, QueryExecuteSubsetResult>();
|
private _querySubsetResultMap: Map<number, QueryExecuteSubsetResult> = new Map<number, QueryExecuteSubsetResult>();
|
||||||
|
private _errorOccurred: boolean = false;
|
||||||
|
private _stopOnError: boolean = true;
|
||||||
constructor(
|
constructor(
|
||||||
private _queryRunner: QueryRunner,
|
private _queryRunner: QueryRunner,
|
||||||
private _executionCount: number | undefined,
|
private _executionCount: number | undefined,
|
||||||
@@ -392,6 +395,7 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
|||||||
if (maxRows && maxRows > 0) {
|
if (maxRows && maxRows > 0) {
|
||||||
this.configuredMaxRows = maxRows;
|
this.configuredMaxRows = maxRows;
|
||||||
}
|
}
|
||||||
|
this._stopOnError = !!config[SqlStopOnErrorConfigName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +430,7 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
|||||||
channel: 'shell',
|
channel: 'shell',
|
||||||
type: 'execute_reply',
|
type: 'execute_reply',
|
||||||
content: {
|
content: {
|
||||||
status: 'ok',
|
status: this._errorOccurred && this._stopOnError ? 'error' : 'ok',
|
||||||
execution_count: this._executionCount
|
execution_count: this._executionCount
|
||||||
},
|
},
|
||||||
header: undefined,
|
header: undefined,
|
||||||
@@ -619,6 +623,8 @@ export class SQLFuture extends Disposable implements FutureInternal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private convertToError(msg: IResultMessage | string): nb.IIOPubMessage {
|
private convertToError(msg: IResultMessage | string): nb.IIOPubMessage {
|
||||||
|
this._errorOccurred = true;
|
||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
let msgData = typeof msg === 'string' ? msg : msg.message;
|
let msgData = typeof msg === 'string' ? msg : msg.message;
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user