Catch exceptions in error handler