Move exception raising to new private function