Refactoring of exception