Added null check guard clause and made exception match Enum.Parse