replacing stderr/exit by an exception