Skip to content

Commit

Permalink
Merge pull request #15623 from seamuslee001/type_check_exceptions
Browse files Browse the repository at this point in the history
dev/core#560 [REF] Throw exceptions for invalid type errors when aborting
  • Loading branch information
seamuslee001 authored Oct 27, 2019
2 parents 19788b7 + d8bf477 commit a393333
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CRM/Core/DAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ public static function composeQuery($query, $params = [], $abort = TRUE) {
$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]}");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion CRM/Utils/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static function escape($data, $type, $abort = TRUE) {
*
* @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',
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contact/BAO/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ public function testContactIDClause() {
}
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);
Expand Down

0 comments on commit a393333

Please sign in to comment.