public
Description: Midgard Components Framework 3rd generation
Homepage: http://www.midgard-project.org
Clone URL: git://github.com/bergie/midcom.git
Deal with missing database connection
bergie (author)
Mon Jun 02 02:48:34 -0700 2008
commit  48d20ba5774241539fa1fef6d6793248b5c66c9a
tree    e4c30d352a28de7244e1a9b14bceaf0a32fa5267
parent  f4239284b62a8e5bee3f7c3db4b21889dbe20fc4
...
21
22
23
 
24
25
26
...
58
59
60
 
61
62
63
...
97
98
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
101
102
...
21
22
23
24
25
26
27
...
59
60
61
62
63
64
65
...
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
0
@@ -21,6 +21,7 @@ class midcom_core_exceptionhandler
0
         {
0
             case 'midcom_exception_notfound':
0
             case 'midcom_exception_unauthorized':
0
+ case 'midcom_exception_httperror':
0
                 $http_code = $exception->getCode();
0
                 break;
0
 
0
@@ -58,6 +59,7 @@ class midcom_core_exceptionhandler
0
             401 => 'HTTP/1.0 401 Unauthorized',
0
             404 => 'HTTP/1.0 404 Not Found',
0
             500 => 'HTTP/1.0 500 Server Error',
0
+ 503 => 'HTTP/1.0 503 Service Unavailable',
0
         );
0
 
0
         if (!isset($headers[$code]))
0
@@ -97,5 +99,19 @@ class midcom_exception_unauthorized extends Exception
0
     }
0
 }
0
 
0
+/**
0
+ * MidCOM 3 generic HTTP error exception
0
+ *
0
+ * @package midcom_core
0
+ */
0
+class midcom_exception_httperror extends Exception
0
+{
0
+ // Redefine the exception so message isn't optional
0
+ public function __construct($message, $code = 500)
0
+ {
0
+ parent::__construct($message, $code);
0
+ }
0
+}
0
+
0
 set_exception_handler(array('midcom_core_exceptionhandler', 'handle'));
0
 ?>
0
\ No newline at end of file
...
21
22
23
 
 
 
 
 
24
25
26
...
21
22
23
24
25
26
27
28
29
30
31
0
@@ -21,6 +21,11 @@ class midcom_core_services_dispatcher_midgard2 extends midcom_core_services_disp
0
         {
0
             throw new Exception('Midgard 2.x is required for this MidCOM setup.');
0
         }
0
+
0
+ if (!is_object($_MIDGARD_CONNECTION->request_config))
0
+ {
0
+ throw new midcom_exception_httperror('Midgard database connection not found.', 503);
0
+ }
0
 
0
         foreach ($_MIDGARD_CONNECTION->request_config->argv as $argument)
0
         {

Comments

    No one has commented yet.