Helper for throwing informative errors in Node.js and the browser