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

Adding ability to send error object to notify() #2955

Merged
merged 2 commits into from
May 2, 2018

Conversation

sonnyg
Copy link
Contributor

@sonnyg sonnyg commented Apr 30, 2018

In short, this pull request is to assist with error reporting, and diagnostics.

After the 2.0 upgrade, a number of plugins I use stopped working. Unfortunately, while I would see the notification message to check 'Developer tools', there was no further output or logs available.

After looking through the source, I found that some catch blocks would output the error to console.error, but others would not. Rather than modifying all the catch blocks, I opted to add an additional parameter 'error', to the notify method. If present, the error is logged to the console. I then just modified the catch block to pass the error reference.

Please do not be bashful with your feedback, and thank you so much for this incredible tool.

@sonnyg
Copy link
Contributor Author

sonnyg commented Apr 30, 2018

BTW, I wanted to add a test for the modifications, but I was not quite clear on asserting calls to the console. If someone can provide me some guidance, I would be more than happy to add theses tests.

app/notify.js Outdated
@@ -27,9 +27,13 @@ app.on('ready', () => {
});
});

function notify(title, body) {
function notify(title, body, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be a good idea to do {error} as an object on the end, so if we need to send more info to notify in the future we don't need to have another positional argument 👍

Copy link
Contributor Author

@sonnyg sonnyg Apr 30, 2018

Choose a reason for hiding this comment

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

It's funny you mention that, because that was actually my first thought!

I had debated about creating 'channels' represented as properties on the object.

{}.error --> console.error
{}.warn --> console.warn
etc ...

@sonnyg
Copy link
Contributor Author

sonnyg commented Apr 30, 2018

@albinekb I modified the parameter as you suggested. Are these changes what you were thinking?

Copy link
Contributor

@albinekb albinekb left a comment

Choose a reason for hiding this comment

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

Very nice!

@albinekb albinekb requested a review from chabou April 30, 2018 20:44
@sonnyg
Copy link
Contributor Author

sonnyg commented Apr 30, 2018

Excellent, thank you so much!

@sonnyg
Copy link
Contributor Author

sonnyg commented Apr 30, 2018

I created a corresponding PR in hyper-site, which updates the API description for 'notify'.

vercel/hyper-site#47

@chabou
Copy link
Contributor

chabou commented May 2, 2018

Thank you for your valuable help 🙏
Great work and a good thing that you made another PR for our documentation 💯

@chabou chabou merged commit f64e3e0 into vercel:canary May 2, 2018
@sonnyg sonnyg deleted the notify-with-error branch May 3, 2018 17:08
@chabou chabou mentioned this pull request May 18, 2018
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants