From df8ad46daef960accd1e307f74e7bcb705e9fc7b Mon Sep 17 00:00:00 2001
From: Bart Visscher <bartv@thisnet.nl>
Date: Sun, 21 Jul 2013 22:29:50 +0200
Subject: [PATCH] Change exit calls to throwing an exception

This way the error won't be fatal in a unit test
---
 lib/app.php    | 3 +--
 lib/files.php  | 4 ++--
 lib/helper.php | 3 +--
 3 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/app.php b/lib/app.php
index baacf508d8..115b7d60f5 100644
--- a/lib/app.php
+++ b/lib/app.php
@@ -839,9 +839,8 @@ class OC_App{
 					OC_Hook::emit('update', 'success', 'Updated '.$info['name'].' app');
 				}
 				catch (Exception $e) {
-					echo 'Failed to upgrade "'.$app.'". Exception="'.$e->getMessage().'"';
 					OC_Hook::emit('update', 'failure', 'Failed to update '.$info['name'].' app: '.$e->getMessage());
-					die;
+					throw new RuntimeException('Failed to upgrade "'.$app.'". Exception="'.$e->getMessage().'"');
 				}
 				OC_Appconfig::setValue($app, 'installed_version', OC_App::getAppVersion($app));
 			}
diff --git a/lib/files.php b/lib/files.php
index f5dffd970d..ce46d13da4 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -62,7 +62,7 @@ class OC_Files {
 			$zip = new ZipArchive();
 			$filename = OC_Helper::tmpFile('.zip');
 			if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
-				exit("cannot open <$filename>\n");
+				throw new Exception("cannot open '$filename'\n");
 			}
 			foreach ($files as $file) {
 				$file = $dir . '/' . $file;
@@ -93,7 +93,7 @@ class OC_Files {
 			$zip = new ZipArchive();
 			$filename = OC_Helper::tmpFile('.zip');
 			if ($zip->open($filename, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE)!==true) {
-				exit("cannot open <$filename>\n");
+				throw new Exception("cannot open '$filename'\n");
 			}
 			$file = $dir . '/' . $files;
 			self::zipAddDir($file, $zip);
diff --git a/lib/helper.php b/lib/helper.php
index df0d120976..ca508e1d93 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -176,8 +176,7 @@ class OC_Helper {
 		}elseif( file_exists( OC::$SERVERROOT."/core/img/$image" )) {
 			return OC::$WEBROOT."/core/img/$image";
 		}else{
-			echo('image not found: image:'.$image.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
-			die();
+			throw new RuntimeException('image not found: image:'.$image.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
 		}
 	}
 
-- 
GitLab