]> source.dussan.org Git - nextcloud-server.git/commitdiff
Change exit calls to throwing an exception
authorBart Visscher <bartv@thisnet.nl>
Sun, 21 Jul 2013 20:29:50 +0000 (22:29 +0200)
committerBart Visscher <bartv@thisnet.nl>
Sun, 21 Jul 2013 20:29:50 +0000 (22:29 +0200)
This way the error won't be fatal in a unit test

lib/app.php
lib/files.php
lib/helper.php

index baacf508d8e280ad185c4a7fe9ca3091a225c938..115b7d60f5e2e2579f4839848207e8f9451e69c1 100644 (file)
@@ -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));
                        }
index f5dffd970d2ca13b817cd96c5c3a65c63dd3a9ab..ce46d13da413154b7b6085738cfacbd035836a44 100644 (file)
@@ -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);
index df0d120976df44e9ef9bff1e701d9efeb9f123cb..ca508e1d9334dd5ad85a308babbd5977ab5b9253 100644 (file)
@@ -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);
                }
        }