def ApplyWrapper(self, solver): try: self.Apply(solver) except Exception as e: if 'CP Solver fail' in str(e): solver.ShouldFail() else: raise