Replaced die()-calls with exceptions where appropriate.
[memberdb.git] / index.php
index e6d51f0..2fc1cd8 100644 (file)
--- a/index.php
+++ b/index.php
@@ -21,41 +21,44 @@ require_once('include/payments.php');
 require_once('include/dtaus.php');
 require_once('include/export.php');
 
-db_connect();
-
-if (!defined('IS_INSTALLED') || !IS_INSTALLED) install_database();
-
-$action = 'list_members';
-if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
-
-ob_start();
-
-switch ($action) {
-    case 'list_members'   : action_list_members();    break;
-    case 'view_member'    : action_view_member();     break;
-    case 'export_email'   : action_export_email();    break;
-    case 'create_member'  : action_create_member();   break;
-    case 'change_member'  : action_change_member();   break;
-    case 'create_event'   : action_create_event();    break;
-    case 'change_event'   : action_change_event();    break;
-    case 'delete_event'   : action_delete_event();    break;
-    case 'create_earnings': action_create_earnings(); break;
-    case 'create_earning' : action_create_earning();  break;
-    case 'change_earning' : action_change_earning();  break;
-    case 'delete_earning' : action_delete_earning();  break;
-    case 'create_expense' : action_create_expense();  break;
-    case 'change_expense' : action_change_expense();  break;
-    case 'delete_expense' : action_delete_expense();  break;
-    case 'cryptography'   : action_cryptography();    break;
-    case 'fees'           : action_fees();            break;
-    case 'dtaus'          : action_dtaus();           break;
-    case 'finances'       : action_finances();        break;
-    case 'export'         : action_export();          break;
-    default: action_404();
-}
 
-$content = ob_get_contents();
-ob_end_clean();
+try {
+
+    db_connect();
+
+    if (!defined('IS_INSTALLED') || !IS_INSTALLED) install_database();
+
+    $action = 'list_members';
+    if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
+
+    ob_start();
+
+    switch ($action) {
+        case 'list_members'   : action_list_members();    break;
+        case 'view_member'    : action_view_member();     break;
+        case 'export_email'   : action_export_email();    break;
+        case 'create_member'  : action_create_member();   break;
+        case 'change_member'  : action_change_member();   break;
+        case 'create_event'   : action_create_event();    break;
+        case 'change_event'   : action_change_event();    break;
+        case 'delete_event'   : action_delete_event();    break;
+        case 'create_earnings': action_create_earnings(); break;
+        case 'create_earning' : action_create_earning();  break;
+        case 'change_earning' : action_change_earning();  break;
+        case 'delete_earning' : action_delete_earning();  break;
+        case 'create_expense' : action_create_expense();  break;
+        case 'change_expense' : action_change_expense();  break;
+        case 'delete_expense' : action_delete_expense();  break;
+        case 'cryptography'   : action_cryptography();    break;
+        case 'fees'           : action_fees();            break;
+        case 'dtaus'          : action_dtaus();           break;
+        case 'finances'       : action_finances();        break;
+        case 'export'         : action_export();          break;
+        default: action_404();
+    }
+
+    $content = ob_get_contents();
+    ob_end_clean();
 
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -146,3 +149,10 @@ ob_end_clean();
     <div id="footer"></div>
     </body>
 </html>
+
+<?php
+
+}
+catch (Exception $e) {
+    echo 'Caught exception: ',  $e->getMessage(), "\n";
+}
\ No newline at end of file