From de1a27d0bf82c9b35693823ca7a1ece529112b9f Mon Sep 17 00:00:00 2001 From: Erich Schulz Date: Tue, 3 Jan 2017 02:34:15 +0000 Subject: [PATCH] throw instead of exit on error --- CRM/Utils/System/Drupal.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index 646b9250f4..0619fce6d7 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -467,8 +467,7 @@ AND u.status = 1 if (!file_exists("$cmsPath/includes/bootstrap.inc")) { if ($throwError) { - echo '
Sorry, could not locate bootstrap.inc\n'; - exit(); + throw new Exception('Sorry, could not locate bootstrap.inc'); } return FALSE; } @@ -489,10 +488,15 @@ AND u.status = 1 // explicitly setting error reporting, since we cannot handle drupal related notices error_reporting(1); - if (!function_exists('module_exists') || !module_exists('civicrm')) { + if (!function_exists('module_exists')) { if ($throwError) { - echo '
Sorry, could not load drupal bootstrap.'; - exit(); + throw new Exception('Sorry, could not load drupal bootstrap.'); + } + return FALSE; + } + if (!module_exists('civicrm')) { + if ($throwError) { + throw new Exception('Sorry, drupal cannot find CiviCRM'); } return FALSE; } @@ -524,8 +528,7 @@ AND u.status = 1 $uid = user_authenticate($name, $pass); if (!$uid) { if ($throwError) { - echo '
Sorry, unrecognized username or password.'; - exit(); + throw new Exception('Sorry, unrecognized username or password.'); } return FALSE; } @@ -542,8 +545,7 @@ AND u.status = 1 } if ($throwError) { - echo '
Sorry, can not load CMS user account.'; - exit(); + throw new Exception('Sorry, can not load CMS user account.'); } // CRM-6948: When using loadBootStrap, it's implicit that CiviCRM has already loaded its settings -- 2.25.1