Catch external mount/umount error messages 48/151348/3
authorLukasz Pawelczyk <l.pawelczyk@samsung.com>
Wed, 20 Sep 2017 12:33:44 +0000 (14:33 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 6 Oct 2017 10:13:29 +0000 (12:13 +0200)
Change-Id: I0d1917f20a5113734635766f4a83a9eb8896e80e

server/external-encryption.cpp

index d20c382..41648a7 100644 (file)
@@ -245,8 +245,15 @@ int ExternalEncryptionServer::mount()
                return 0;
        }
 
-       engine->mount(mountKey, getOptions());
-       mountKey.clear();
+       INFO(SINK, "Mount external storage...");
+       try {
+               engine->mount(mountKey, getOptions());
+               mountKey.clear();
+       } catch (runtime::Exception &e) {
+               mountKey.clear();
+               ERROR(SINK, "Failed to mount: " + std::string(e.what()));
+               return -3;
+       }
 
        context.notify("ExternalEncryptionServer::mount");
 
@@ -267,7 +274,12 @@ int ExternalEncryptionServer::umount()
        INFO(SINK, "Close all applications using external storage...");
        killDependentApplications(EXTERNAL_PATH);
        INFO(SINK, "Umount external storage...");
-       engine->umount();
+       try {
+               engine->umount();
+       } catch (runtime::Exception &e) {
+               ERROR(SINK, "Failed to umount: " + std::string(e.what()));
+               return -3;
+       }
 
        return 0;
 }