Error handler for console and ajax errors