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

Conversation

aherlihy
Copy link
Contributor

@aherlihy aherlihy commented Dec 19, 2016

more details›

Unexpected error notification

Developer Notes

The only slightly iffy part about this is that the notification has a terminal icon as well as the compass icon, which is a known issue with node-notifier.

@@ -7,6 +7,8 @@ var format = require('util').format;
var ipc = require('hadron-ipc');
var intercom = require('./intercom');
var features = require('./features');
var Notifier = require('node-notifier');
var process = require('process');
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need to require process here - it is a global variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

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

window.addEventListener('error', function(err) {
debug('error encountered, notify trackers', err);
// Notify user that error occurred
if (!_.includes(err.message, 'MongoError')) {
var icon = pkg.config.hadron.build.win32.icon;
Copy link
Member

Choose a reason for hiding this comment

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

If you're intent on being able to change the reference to this variable, I would use ES6 syntax instead and use let icon instead of var icon. However, my personal preference would be to treat it as a const and use a ternary operator to set the value, like:

const icon = (process.platform === 'darwin') ?
  pkg.config.hadron.build.darwin.icon : pkg.config.hadron.build.win32.icon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I can change it to a ternary statement. Is this a style issue or does it have other effects?

@@ -94,6 +96,19 @@ 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. :)

@durran
Copy link
Member

durran commented Dec 21, 2016

LGTM

@aherlihy aherlihy merged commit 9de5718 into mongodb-js:master Dec 21, 2016
@imlucas imlucas changed the title COMPASS-375 - Add OS notification for unexpected non-MongoError errors. COMPASS-375: Tell the user when an unexpected error occurs Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants