Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COMPASS-375: Tell the user when an unexpected error occurs #702

Merged
merged 2 commits into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"mongodb-shell-to-url": "^0.1.0",
"ms": "^0.7.1",
"ncp": "^2.0.0",
"node-notifier": "^4.3.1",
"numeral": "^1.5.3",
"pluralize": "^1.2.1",
"qs": "^5.2.0",
Expand Down
12 changes: 12 additions & 0 deletions src/app/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var format = require('util').format;
var ipc = require('hadron-ipc');
var intercom = require('./intercom');
var features = require('./features');
var Notifier = require('node-notifier');

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

Expand Down Expand Up @@ -94,6 +95,17 @@ module.exports = function() {

window.addEventListener('error', function(err) {
debug('error encountered, notify trackers', err);
// Notify user that error occurred
if (!_.includes(err.message, 'MongoError')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't check the message to determine if the error is a MongoError - I would use the name attribute, as all MongoErrors set the name attribute to MongoError: https://github.com/christkv/mongodb-core/blob/2.0/lib/error.js#L11

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MongoErrors do have that name but the error object passed to the function isn't the error itself, it's been modified to look like:

screen shot 2016-12-20 at 5 49 34 pm 1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok sorry... Thought it was the actual error. :)

const icon = (process.platform === 'darwin') ?
pkg.config.hadron.build.darwin.icon : pkg.config.hadron.build.win32.icon;
Notifier.notify({
'icon': icon,
'message': 'Unexpected error occurred: ' + err.message,
'title': 'MongoDB Compass Exception',
'wait': true
});
}
metrics.error(err);
});

Expand Down