FixBug: error handling in async logics in content-screening.cpp 85/74185/1
authorKyungwook Tak <k.tak@samsung.com>
Mon, 13 Jun 2016 06:13:58 +0000 (15:13 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Mon, 13 Jun 2016 06:15:13 +0000 (15:15 +0900)
After error, exception should be thrown. If async task returned
normally, it's considered as success case and completed callback called.

Change-Id: I929ccc8c1e5ee124f74a8588a927b07f453b673a
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/client/content-screening.cpp

index 3da1843..f9d0fcc 100644 (file)
@@ -29,6 +29,7 @@
 #include "client/async-logic.h"
 #include "client/canonicalize.h"
 #include "common/macros.h"
+#include "common/exception.h"
 #include "common/types.h"
 #include "common/cs-context.h"
 #include "common/cs-detected.h"
@@ -392,12 +393,9 @@ int csr_cs_scan_files_async(csr_cs_context_h handle, const char *file_paths[],
                auto ret = hExt->dispatch<std::pair<int, std::shared_ptr<StrSet>>>(
                                        CommandId::CANONICALIZE_PATHS, *fileSet);
 
-               if (ret.first != CSR_ERROR_NONE) {
-                       if (hExt->m_cb.onError)
-                               hExt->m_cb.onError(ret.first, user_data);
-
-                       return;
-               }
+               if (ret.first != CSR_ERROR_NONE)
+                       ThrowExc(ret.first, "Error on getting canonicalized paths in subthread. "
+                                        "ret: " << ret.first);
 
                std::shared_ptr<StrSet> canonicalizedFiles;
 
@@ -494,12 +492,9 @@ int csr_cs_scan_dirs_async(csr_cs_context_h handle, const char *dir_paths[],
                auto ret = hExt->dispatch<std::pair<int, std::shared_ptr<StrSet>>>(
                                        CommandId::CANONICALIZE_PATHS, *dirSet);
 
-               if (ret.first != CSR_ERROR_NONE) {
-                       if (hExt->m_cb.onError)
-                               hExt->m_cb.onError(ret.first, user_data);
-
-                       return;
-               }
+               if (ret.first != CSR_ERROR_NONE)
+                       ThrowExc(ret.first, "Error on getting canonicalized paths in subthread. "
+                                        "ret: " << ret.first);
 
                std::shared_ptr<StrSet> canonicalizedDirs;