[REF] Throw execptions for invalid type erorrs when aborting
authorSeamus Lee <seamuslee001@gmail.com>
Sun, 27 Oct 2019 00:57:53 +0000 (11:57 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 27 Oct 2019 00:57:53 +0000 (11:57 +1100)
CRM/Core/DAO.php
CRM/Utils/Type.php
tests/phpunit/CRM/Contact/BAO/QueryTest.php

index cadce9c18c730d7d2afdade9ab6a550feac78719..0a09592556b1a00074e985c4e1f2dc753725946d 100644 (file)
@@ -1550,7 +1550,7 @@ FROM   civicrm_domain
           $tr['%' . $key] = $item[0];
         }
         elseif ($abort) {
-          CRM_Core_Error::fatal("{$item[0]} is not of type {$item[1]}");
+          throw new CRM_Core_Exception("{$item[0]} is not of type {$item[1]}");
         }
       }
     }
index 483e5629b1767c32cb56749b9616f506d095f939..07a2fd74d02517aae39febf5646c1c01bcf97246 100644 (file)
@@ -376,7 +376,7 @@ class CRM_Utils_Type {
    *
    * @throws \CRM_Core_Exception
    */
-  public static function validate($data, $type, $abort = TRUE, $name = 'One of parameters ', $isThrowException = FALSE) {
+  public static function validate($data, $type, $abort = TRUE, $name = 'One of parameters ', $isThrowException = TRUE) {
 
     $possibleTypes = [
       'Integer',
index 24dba459aba4f63d99c2448da49e1c99adc6d68d..b206e6f73caa7635add9755bbacc8f55686b6160 100644 (file)
@@ -898,7 +898,7 @@ civicrm_relationship.is_active = 1 AND
     }
     catch (Exception $e) {
       $this->assertEquals(
-        "A fatal error was triggered: One of parameters  (value: foo@example.com) is not of the type Positive",
+        "One of parameters  (value: foo@example.com) is not of the type Positive",
         $e->getMessage()
       );
       $this->assertTrue(TRUE);