use def to create exceptions instead of val so they aren't needlessly created on each call