throw instead of exit on error
authorErich Schulz <erichbschulz@gmail.com>
Tue, 3 Jan 2017 02:34:15 +0000 (02:34 +0000)
committerErich Schulz <erichbschulz@gmail.com>
Tue, 3 Jan 2017 03:46:28 +0000 (03:46 +0000)
CRM/Utils/System/Drupal.php

index 646b9250f45644feeb71f9ba32b7d7112c7a0456..0619fce6d7bdbd1e2e576c9fb951a8fee4b5d319 100644 (file)
@@ -467,8 +467,7 @@ AND    u.status = 1
 
     if (!file_exists("$cmsPath/includes/bootstrap.inc")) {
       if ($throwError) {
-        echo '<br />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 '<br />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 '<br />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 '<br />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