Improve the error handler