Cleaner exception handling code