Handle exceptions in controllers