Skip to content

Commit c1d0e3e

Browse files
committed
feat(errors): report errors to the user with notifications
1 parent 4f92f89 commit c1d0e3e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/notebook/kernel/shutdown.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export function cleanupKernel(kernel, closeChannels, _fs = fs) {
1111
kernel.channels.stdin.complete();
1212
kernel.channels.control.complete();
1313
} catch (err) {
14-
// nom nom nom
1514
console.warn(`Could not cleanup kernel channels, have they already
1615
been completed?`, kernel.channels);
1716
}

src/notebook/middlewares.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,34 @@ import * as constants from './constants';
77

88
const rootEpic = combineEpics(...epics);
99

10+
const errorMiddleware = store => next => action => {
11+
if (!action.type.includes('ERROR')) {
12+
return next(action);
13+
}
14+
console.error(action);
15+
let errorText;
16+
if (action.payload) {
17+
errorText = action.payload;
18+
} else {
19+
errorText = JSON.stringify(action, 2, 2);
20+
}
21+
const state = store.getState();
22+
const notificationSystem = state.app.get('notificationSystem');
23+
if (notificationSystem) {
24+
notificationSystem.addNotification({
25+
title: action.type,
26+
message: errorText,
27+
dismissible: true,
28+
position: 'tr',
29+
level: 'error',
30+
});
31+
}
32+
return next(action);
33+
};
34+
1035
const middlewares = [
1136
createEpicMiddleware(rootEpic),
37+
errorMiddleware,
1238
];
1339

1440
export default middlewares;

0 commit comments

Comments
 (0)