check that error exists

Sorry for the lame PR, but I accidentally passed in undefined and ended up with infinite complaints of ` TypeError: Cannot read property 'stack' of undefined`.