bitHound Blog

Find ignored callback errors with bitHound

View ignored errors on bitHound

An error-first callback is a very popular pattern in asynchronous JavaScript, as is often used in node.js and io.js. By using this pattern, we can pass errors along the call chain nicely until it's properly handled. However, even the best of us often forget to check for these errors before proceeding.

To help with these errors, bitHound will now inform you of the callbacks in your code where the error argument is ignored. Going forward, all future commits will also incorporate this analysis.

"But I know what I'm doing and I meant to ignore that error!"

While that might work well for you, we appreciate code that takes continuity and maintainability into account. Instead, you could wrap the error with an empty if statement and a comment so that the next person looking at that code knows that the error is being ignored intentionally.

Why not consider something like this:

function (err, stuff) {  
if (err) { /* This error can totally be ignored because awesome */ }

//continue with the rest


For the cases where you did happen to forget, bitHound has your back :-).

This analysis will be presented just like all of our other badges. It's just one more thing bitHound is doing to try and help you write the best JavaScript software possible!

bitHound identifies risks and priorities in your Node.js projects.