diff --git a/src/sql/parts/notebook/outputs/common/outputProcessor.ts b/src/sql/parts/notebook/outputs/common/outputProcessor.ts index d08656dd2c..b684918646 100644 --- a/src/sql/parts/notebook/outputs/common/outputProcessor.ts +++ b/src/sql/parts/notebook/outputs/common/outputProcessor.ts @@ -40,8 +40,12 @@ export function getData(output: nb.ICellOutput): JSONObject { } } else if (nbformat.isError(output)) { let traceback = output.traceback ? output.traceback.join('\n') : undefined; - bundle['application/vnd.jupyter.stderr'] = - traceback || `${output.ename}: ${output.evalue}`; + bundle['application/vnd.jupyter.stderr'] = undefined; + if (traceback && traceback !== '') { + bundle['application/vnd.jupyter.stderr'] = traceback; + } else if (output.evalue) { + bundle['application/vnd.jupyter.stderr'] = output.ename && output.ename !== '' ? `${output.ename}: ${output.evalue}` : `${output.evalue}`; + } } return convertBundle(bundle); } diff --git a/src/sql/workbench/services/notebook/common/sqlSessionManager.ts b/src/sql/workbench/services/notebook/common/sqlSessionManager.ts index 8271f24126..05defe28dd 100644 --- a/src/sql/workbench/services/notebook/common/sqlSessionManager.ts +++ b/src/sql/workbench/services/notebook/common/sqlSessionManager.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; -import { nb, QueryExecuteSubsetResult, IDbColumn, BatchSummary } from 'sqlops'; +import { nb, QueryExecuteSubsetResult, IDbColumn, BatchSummary, IResultMessage } from 'sqlops'; import { localize } from 'vs/nls'; import { FutureInternal } from 'sql/parts/notebook/models/modelInterfaces'; import QueryRunner, { EventType } from 'sql/platform/query/common/queryRunner'; @@ -246,8 +246,8 @@ class SqlKernel extends Disposable implements nb.IKernel { })); this._register(queryRunner.addListener(EventType.MESSAGE, message => { // TODO handle showing a messages output (should be updated with all messages, only changing 1 output in total) - if (message.isError) { - this._errorMessageService.showDialog(Severity.Error, sqlKernelError, message.message); + if (this._future) { + this._future.handleMessage(message); } })); this._register(queryRunner.addListener(EventType.BATCH_COMPLETE, batch => { @@ -261,24 +261,6 @@ class SqlKernel extends Disposable implements nb.IKernel { if (this._future) { this._future.handleDone(); } - // let batches = this._queryRunner.batchSets; - // // currently only support 1 batch set 1 resultset - // if (batches.length > 0) { - // let batch = batches[0]; - // if (batch.resultSetSummaries.length > 0 - // && batch.resultSetSummaries[0].rowCount > 0 - // ) { - // let resultset = batch.resultSetSummaries[0]; - // this._columns = resultset.columnInfo; - // let rows: QueryExecuteSubsetResult; - // try { - // rows = await this._queryRunner.getQueryRows(0, resultset.rowCount, batch.id, resultset.id); - // } catch (e) { - // return Promise.reject(e); - // } - // this._rows = rows.resultSubset.rows; - // } - // } // TODO issue #2746 should ideally show a warning inside the dialog if have no data } } @@ -340,6 +322,18 @@ export class SQLFuture extends Disposable implements FutureInternal { // no-op } + public handleMessage(msg: IResultMessage): void { + if (this.ioHandler) { + let message; + if (msg.isError) { + message = this.convertToError(msg); + } else { + message = this.convertToDisplayMessage(msg); + } + this.ioHandler.handle(message); + } + } + public handleBatchEnd(batch: BatchSummary): void { if (this.ioHandler) { for (let resultSet of batch.resultSetSummaries) { @@ -424,6 +418,51 @@ export class SQLFuture extends Disposable implements FutureInternal { let tableHtml = '