Fixing raising custom exception