Skip to content

Commit 6b3b581

Browse files
committed
better errrors
1 parent 3a757ba commit 6b3b581

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/notebooks/deepnote/deepnoteNotebookCommandListener.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { IExtensionSyncActivationService } from '../../platform/activation/types
1717
import { IDisposableRegistry } from '../../platform/common/types';
1818
import { Commands } from '../../platform/common/constants';
1919
import { chainWithPendingUpdates } from '../../kernels/execution/notebookUpdater';
20+
import { WrappedError } from '../../platform/errors/types';
2021
import {
2122
DeepnoteBigNumberMetadataSchema,
2223
DeepnoteTextInputMetadataSchema,
@@ -269,12 +270,11 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
269270
const editor = window.activeNotebookEditor;
270271

271272
if (!editor) {
272-
throw new Error(l10n.t('No active notebook editor found'));
273+
throw new WrappedError(l10n.t('No active notebook editor found'));
273274
}
274275

275276
const document = editor.notebook;
276277
const selection = editor.selection;
277-
278278
const insertIndex = selection ? selection.end : document.cellCount;
279279

280280
const defaultVisualizationSpec = {
@@ -310,7 +310,7 @@ export class DeepnoteNotebookCommandListener implements IExtensionSyncActivation
310310
});
311311

312312
if (result !== true) {
313-
throw new Error(l10n.t('Failed to insert chart block'));
313+
throw new WrappedError(l10n.t('Failed to insert chart block'));
314314
}
315315

316316
const notebookRange = new NotebookRange(insertIndex, insertIndex + 1);

src/notebooks/deepnote/deepnoteNotebookCommandListener.unit.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
import { IDisposable } from '../../platform/common/types';
2222
import * as notebookUpdater from '../../kernels/execution/notebookUpdater';
2323
import { createMockedNotebookDocument } from '../../test/datascience/editor-integration/helpers';
24+
import { WrappedError } from '../../platform/errors/types';
2425

2526
suite('DeepnoteNotebookCommandListener', () => {
2627
let commandListener: DeepnoteNotebookCommandListener;
@@ -1138,7 +1139,11 @@ suite('DeepnoteNotebookCommandListener', () => {
11381139
});
11391140

11401141
// Call the method and expect rejection
1141-
await assert.isRejected(commandListener.addChartBlock(), Error, 'No active notebook editor found');
1142+
await assert.isRejected(
1143+
commandListener.addChartBlock(),
1144+
WrappedError,
1145+
'No active notebook editor found'
1146+
);
11421147
});
11431148

11441149
test('should throw error when chainWithPendingUpdates fails', async () => {
@@ -1154,7 +1159,7 @@ suite('DeepnoteNotebookCommandListener', () => {
11541159
sandbox.stub(notebookUpdater, 'chainWithPendingUpdates').resolves(false);
11551160

11561161
// Call the method and expect rejection
1157-
await assert.isRejected(commandListener.addChartBlock(), Error, 'Failed to insert chart block');
1162+
await assert.isRejected(commandListener.addChartBlock(), WrappedError, 'Failed to insert chart block');
11581163
});
11591164
});
11601165
});

0 commit comments

Comments
 (0)