diff --git a/core/command/upgrade.php b/core/command/upgrade.php
index 58e98e2bbdcc8898d131332b965da93e42a2640a..cf376148a0026344433d5099bbb6e6102b4609c7 100644
--- a/core/command/upgrade.php
+++ b/core/command/upgrade.php
@@ -39,8 +39,7 @@ class Upgrade extends Command {
 	const ERROR_MAINTENANCE_MODE = 2;
 	const ERROR_UP_TO_DATE = 3;
 	const ERROR_INVALID_ARGUMENTS = 4;
-
-	public $upgradeFailed = false;
+	const ERROR_FAILURE = 5;
 
 	/**
 	 * @var IConfig
@@ -128,10 +127,11 @@ class Upgrade extends Command {
 				$output->writeln('<info>Maintenance mode is kept active</info>');
 			});
 			$updater->listen('\OC\Updater', 'updateEnd',
-				function () use($output, $updateStepEnabled, $self) {
+				function ($success) use($output, $updateStepEnabled, $self) {
 					$mode = $updateStepEnabled ? 'Update' : 'Update simulation';
-					$status = $self->upgradeFailed ? 'failed' : 'successful';
-					$message = "<info>$mode $status</info>";
+					$status = $success ? 'successful' : 'failed' ;
+					$type = $success ? 'info' : 'error';
+					$message = "<$type>$mode $status</$type>";
 					$output->writeln($message);
 				});
 			$updater->listen('\OC\Updater', 'dbUpgrade', function () use($output) {
@@ -166,13 +166,16 @@ class Upgrade extends Command {
 			});
 			$updater->listen('\OC\Updater', 'failure', function ($message) use($output, $self) {
 				$output->writeln("<error>$message</error>");
-				$self->upgradeFailed = true;
 			});
 
-			$updater->upgrade();
+			$success = $updater->upgrade();
 
 			$this->postUpgradeCheck($input, $output);
 
+			if(!$success) {
+				return self::ERROR_FAILURE;
+			}
+
 			return self::ERROR_SUCCESS;
 		} else if($this->config->getSystemValue('maintenance', false)) {
 			//Possible scenario: ownCloud core is updated but an app failed
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index 212deb24b7ae8faf9505a7de86f6b56afe619860..14757c83950f37b7ba3996cd2baf16128ada57df 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -382,7 +382,7 @@ class Filesystem {
 
 		if (is_null($userObject)) {
 			\OCP\Util::writeLog('files', ' Backends provided no user object for ' . $user, \OCP\Util::ERROR);
-			throw new \OC\User\NoUserException();
+			throw new \OC\User\NoUserException('Backends provided no user object for ' . $user);
 		}
 
 		$homeStorage = \OC_Config::getValue('objectstore');
diff --git a/lib/private/updater.php b/lib/private/updater.php
index bd9e8a65363d71c593c4f3119306e7586ccc10a8..00c6569a52f53690b7f2c1a25eb84cf4eced44af 100644
--- a/lib/private/updater.php
+++ b/lib/private/updater.php
@@ -189,20 +189,25 @@ class Updater extends BasicEmitter {
 			$this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core'));
 		}
 
+		$success = true;
 		try {
 			$this->doUpgrade($currentVersion, $installedVersion);
 		} catch (\Exception $exception) {
-			$this->emit('\OC\Updater', 'failure', array($exception->getMessage()));
+			\OCP\Util::logException('update', $exception);
+			$this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage()));
+			$success = false;
 		}
 
-		$this->emit('\OC\Updater', 'updateEnd');
+		$this->emit('\OC\Updater', 'updateEnd', array($success));
 
-		if(!$wasMaintenanceModeEnabled) {
+		if(!$wasMaintenanceModeEnabled && $success) {
 			$this->config->setSystemValue('maintenance', false);
 			$this->emit('\OC\Updater', 'maintenanceDisabled');
 		} else {
 			$this->emit('\OC\Updater', 'maintenanceActive');
 		}
+
+		return $success;
 	}
 
 	/**