exception handling refactoring