From d8bf477d1e793b8108ab6746c545c0c2909e209d Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 27 Oct 2019 11:57:53 +1100 Subject: [PATCH] [REF] Throw execptions for invalid type erorrs when aborting --- CRM/Core/DAO.php | 2 +- CRM/Utils/Type.php | 2 +- tests/phpunit/CRM/Contact/BAO/QueryTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index cadce9c18c..0a09592556 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -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]}"); } } } diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 483e5629b1..07a2fd74d0 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -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', diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index 24dba459ab..b206e6f73c 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -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); -- 2.25.1