Skip to content

Commit

Permalink
MDL-20699 more abstraction in default exception handler
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Nov 1, 2009
1 parent 695c5ec commit a56c457
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions lib/setuplib.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,6 @@ function __construct($hint, $debuginfo=null) {
function default_exception_handler($ex) {
global $DB, $OUTPUT;

if ($DB) {
// If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish
$DB->set_debug(0);
}

// detect active db transactions, rollback and log as error
abort_all_db_transactions();

Expand All @@ -187,6 +182,10 @@ function default_exception_handler($ex) {
echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
} else {
try {
if ($DB) {
// If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish
$DB->set_debug(0);
}
echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
} catch (Exception $out_ex) {
// default exception handler MUST not throw any exceptions!!
Expand Down
5 changes: 3 additions & 2 deletions lib/upgradelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,9 @@ function external_delete_descriptions($component) {
* upgrade logging functions
*/
function upgrade_handle_exception($ex, $plugin = null) {
// rollback everything, we need to log all upgrade problems
abort_all_db_transactions();

$info = get_exception_info($ex);

// First log upgrade error
Expand Down Expand Up @@ -1174,7 +1177,6 @@ function install_core($version, $verbose) {

print_upgrade_part_end(null, true, $verbose);
} catch (exception $ex) {
//TODO: unconditionally rollback DB transaction if active
upgrade_handle_exception($ex);
}
}
Expand Down Expand Up @@ -1225,7 +1227,6 @@ function upgrade_core($version, $verbose) {

print_upgrade_part_end('moodle', false, $verbose);
} catch (Exception $ex) {
//TODO: unconditionally rollback DB transaction if active
upgrade_handle_exception($ex);
}
}
Expand Down

0 comments on commit a56c457

Please sign in to comment.