diff --git a/mdeploy.php b/mdeploy.php index 27f50262fa0..8e5bfec9da2 100644 --- a/mdeploy.php +++ b/mdeploy.php @@ -611,6 +611,49 @@ class output_http_provider extends output_provider { public function help() { // No help available via HTTP } + + /** + * Display the information about uncaught exception + * + * @param Exception $e uncaught exception + */ + public function exception(Exception $e) { + $this->start_output(); + echo('
Moodle deployment utility had a trouble with your request. See the debugging information for more details.
'); + echo('');
+ echo exception_handlers::format_exception_info($e);
+ echo('');
+ $this->end_output();
+ }
+
+ // End of external API
+
+ /**
+ * Produce the HTML page header
+ */
+ protected function start_output() {
+ echo '
+
+
+
+
+
+
+Moodle deployment utility had a trouble with your request. See the debugging information for more details.
'); + echo('');
+ echo self::format_exception_info($e);
+ echo('');
+ }
+
+ /**
+ * Default exception handler
+ *
+ * When this handler is used, input_manager and output_manager singleton instances already
+ * exist in the memory and can be used.
+ *
+ * @param Exception $e uncaught exception
+ */
+ public static function default_exception_handler(Exception $e) {
+
+ $worker = worker::instance();
+ $worker->log_exception($e);
+
+ $output = output_manager::instance();
+ $output->exception($e);
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
// Check if the script is actually executed or if it was just included by someone
@@ -1177,8 +1300,10 @@ class worker extends singleton_pattern {
// if __name__ == '__main__'
if (!debug_backtrace()) {
// We are executed by the SAPI.
+ exception_handlers::set_handler('bootstrap');
// Initialize the worker class to actually make the job.
$worker = worker::instance();
+ exception_handlers::set_handler('default');
// Lights, Camera, Action!
$worker->execute();