Common infrastructure for throwing exceptions