maybe this could be merged with errorHandler.js?