Refactoring of error raising