Skip to content

Commit 2fd68ab

Browse files
committed
COMPASS-375 - Add OS notification for unexpected non-MongoError errors.
1 parent f4cc324 commit 2fd68ab

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@
143143
"mongodb-shell-to-url": "^0.1.0",
144144
"ms": "^0.7.1",
145145
"ncp": "^2.0.0",
146+
"node-notifier": "^4.3.1",
146147
"numeral": "^1.5.3",
147148
"pluralize": "^1.2.1",
148149
"qs": "^5.2.0",

src/app/metrics/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ var format = require('util').format;
77
var ipc = require('hadron-ipc');
88
var intercom = require('./intercom');
99
var features = require('./features');
10+
var Notifier = require('node-notifier');
11+
var process = require('process');
1012

1113
var debug = require('debug')('mongodb-compass:metrics');
1214

@@ -94,6 +96,19 @@ module.exports = function() {
9496

9597
window.addEventListener('error', function(err) {
9698
debug('error encountered, notify trackers', err);
99+
// Notify user that error occurred
100+
if (!_.includes(err.message, 'MongoError')) {
101+
var icon = pkg.config.hadron.build.win32.icon;
102+
if (process.platform === 'darwin') {
103+
icon = pkg.config.hadron.build.darwin.icon;
104+
}
105+
Notifier.notify({
106+
'icon': icon,
107+
'message': 'Unexpected error occurred: ' + err.message,
108+
'title': 'MongoDB Compass Exception',
109+
'wait': true
110+
});
111+
}
97112
metrics.error(err);
98113
});
99114

0 commit comments

Comments
 (0)