applied the DRY principle to the raise exception if constrain creation went badly.