Refactoring constants and throwing correct exception