Merge pull request #22579 from eileenmcnaughton/api4
[civicrm-core.git] / Civi / Payment / PropertyBag.php
index 175abf84ed51615e4d7ad0b5278d8af9ccc1d54c..24987057ef23e95069a66eb1f8a4c2d5ce9124eb 100644 (file)
@@ -1073,7 +1073,10 @@ class PropertyBag implements \ArrayAccess {
    */
   public function setRecurInstallments($recurInstallments, $label = 'default') {
     // Counts zero as positive which is ok - means no installments
-    if (!\CRM_Utils_Type::validate($recurInstallments, 'Positive')) {
+    try {
+      \CRM_Utils_Type::validate($recurInstallments, 'Positive');
+    }
+    catch (\CRM_Core_Exception $e) {
       throw new InvalidArgumentException('recurInstallments must be 0 or a positive integer');
     }