tj / node-growl

growl unobtrusive notification system for nodejs
481 stars 64 forks source link

Callback not receiving errors #72

Closed chadrickman closed 6 years ago

chadrickman commented 6 years ago

The callback was not being passed the error that was being thrown by node-growl. I changed the logic to first see if the error was set and if so pass that. If error is not set than resume the original logic of checking the code and returning null if it's 0 or the value of code if its greater than 0.

I wasn't sure if there was something that was relying on this logic, though there shouldn't be any cases now where the code would be greater than 0 and there not be an error.

This is my first PR, please let me know if I can provide any more details.

deiga commented 6 years ago

@chadrickman Thanks for your contribution! Since a double ternary is a bit hard to read, could you rewrite it to be a bit more readable?

chadrickman commented 6 years ago

@deiga - Ya. Actually, after reviewing node's documentation I realized that the child process would only ever return anything other than 0 if there is an error since in the event of an error we're returning the error, that code will never be reached. So I've removed the check and updated the unit tests to reflect that.