Is there a better way to do this? We raise the same exception further on in the file, so it'd be great to find a way to consolidate this so it occurs in only one spot/