Improving rudimentary error handler