From: Michael Gapczynski Date: Sat, 5 Jan 2013 17:13:36 +0000 (-0500) Subject: Tweak failure message and throw exceptions from updateDbFromStructure() X-Git-Tag: v5.0.0alpha1~258^2~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f6426cee047e435fbed020105ef4e896b68b1e10;p=nextcloud-server.git Tweak failure message and throw exceptions from updateDbFromStructure() --- diff --git a/core/ajax/update.php b/core/ajax/update.php index 1c77a4ab67e..20ab045c892 100644 --- a/core/ajax/update.php +++ b/core/ajax/update.php @@ -10,11 +10,12 @@ if (OC::checkUpgrade(false)) { OC_Hook::connect('update', 'error', $watcher, 'error'); OC_Hook::connect('update', 'error', $watcher, 'failure'); $watcher->success('Turned on maintenance mode'); - $result = OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml'); - if (!$result) { - $watcher->failure('Error updating database'); + try { + $result = OC_DB::updateDbFromStructure(OC::$SERVERROOT.'/db_structure.xml'); + $watcher->success('Updated database'); + } catch (Exception $exception) { + $watcher->failure($exception->getMessage()); } - $watcher->success('Updated database'); $minimizerCSS = new OC_Minimizer_CSS(); $minimizerCSS->clearCache(); $minimizerJS = new OC_Minimizer_JS(); diff --git a/lib/app.php b/lib/app.php index 48bbe53c744..9d4ead71b90 100755 --- a/lib/app.php +++ b/lib/app.php @@ -642,7 +642,7 @@ class OC_App{ } catch (Exception $e) { echo 'Failed to upgrade "'.$app.'". Exception="'.$e->getMessage().'"'; - OC_Hook::emit('update', 'failure', 'Error updating '.$info['name'].' app: '.$e->getMessage()); + OC_Hook::emit('update', 'failure', 'Failed to update '.$info['name'].' app: '.$e->getMessage()); die; } OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app)); diff --git a/lib/db.php b/lib/db.php index 7e60b41d230..74e7ca5b0e0 100644 --- a/lib/db.php +++ b/lib/db.php @@ -495,8 +495,9 @@ class OC_DB { if (PEAR::isError($previousSchema)) { $error = $previousSchema->getMessage(); $detail = $previousSchema->getDebugInfo(); - OC_Log::write('core', 'Failed to get existing database structure for upgrading ('.$error.', '.$detail.')', OC_Log::FATAL); - return false; + $message = 'Failed to get existing database structure for updating ('.$error.', '.$detail.')'; + OC_Log::write('core', $message, OC_Log::FATAL); + throw new Exception($message); } // Make changes and save them to an in-memory file @@ -523,8 +524,9 @@ class OC_DB { if (PEAR::isError($op)) { $error = $op->getMessage(); $detail = $op->getDebugInfo(); - OC_Log::write('core', 'Failed to update database structure ('.$error.', '.$detail.')', OC_Log::FATAL); - return false; + $message = 'Failed to update database structure ('.$error.', '.$detail.')'; + OC_Log::write('core', $message, OC_Log::FATAL); + throw new Exception($message); } return true; }