Remove redundant exception handlings 48/123248/1
authorMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 5 Apr 2017 05:07:53 +0000 (14:07 +0900)
committerMu-Woong Lee <muwoong.lee@samsung.com>
Wed, 5 Apr 2017 05:07:53 +0000 (14:07 +0900)
Change-Id: I3c8c004a63e4ac093b91f3ec1f84b53a816e93fc
Signed-off-by: Mu-Woong Lee <muwoong.lee@samsung.com>
src/client/ContextStore.cpp
src/client/PlatformManagedStore.cpp
src/client/context_store.cpp
src/server/ContextStoreClient.cpp
src/server/ContextStoreService.cpp
src/server/DatabaseManager.cpp
src/server/SchemaLoader.cpp
src/server/StoreManager.cpp

index 1e4d4a9..9539b27 100644 (file)
@@ -72,7 +72,7 @@ DataType ContextStore::getColumnType(const std::string& columnName)
                } else if (typeChar == *COL_STRING) {
                        type = DataType::STRING;
                }
-       } catch (std::exception& e) {
+       } catch (const std::exception& e) {
                _E("%s", e.what());
        }
 
index 81491c7..ace3f7e 100644 (file)
@@ -82,7 +82,7 @@ int PlatformManagedStore::retrieve(const ContextStoreSearchQuery& query, std::ve
 
        try {
                *records = Tuple::buildFrom(vals);
-       } catch (std::exception& e) {
+       } catch (const std::exception& e) {
                _E("Exception: %s", e.what());
                error = E_FAILED;
        }
index 376da75..9aeffe5 100644 (file)
@@ -107,7 +107,7 @@ EXPORT_API int ctx_store_insert(ctx_store_h store, ctx_store_record_h record)
        try {
                auto tuple = builder.build();
                return store->proxy->insert(columns, tuple);
-       } catch (std::exception& e) {
+       } catch (const std::exception& e) {
                return E_FAILED;
        }
 }
index 444852e..9985854 100644 (file)
@@ -51,12 +51,9 @@ void ContextStoreClient::onMethodCalled(MethodCall* methodCall)
                } else if (methodCall->getMethodName() == METHOD_REMOVE) {
                        __remove(*store, *methodCall);
                }
-       } catch (int error) {
+       } catch (const int error) {
                _W("Catch: %s", CTX_ERROR_STR(error));
                methodCall->reply(error);
-       } catch (std::exception& e) {
-               _E("Exception: %s", e.what());
-               methodCall->reply(E_FAILED);
        }
 
        delete methodCall;
index 00993fd..2c138e8 100644 (file)
@@ -61,7 +61,7 @@ void ContextStoreService::cleanup()
 
 ClientBase* ContextStoreService::createClient(const std::string& busName)
 {
-       return new(std::nothrow) ContextStoreClient(this, busName);
+       return new ContextStoreClient(this, busName);
 }
 
 void ContextStoreService::onUserActivated()
@@ -85,12 +85,7 @@ StoreManager& ContextStoreService::getStoreManager()
        if (__storeManager)
                return *__storeManager;
 
-       __storeManager = new(std::nothrow) StoreManager();
-
-       while (__storeManager == NULL) {
-               _W("Memory allocation failed");
-               __storeManager = new(std::nothrow) StoreManager();
-       }
+       __storeManager = new StoreManager();
 
        return *__storeManager;
 }
index bb5a3bb..acc51c1 100644 (file)
@@ -30,8 +30,7 @@ bool DatabaseManager::openSystem()
 {
        IF_FAIL_RETURN(!isSystemReady(), true);
 
-       __systemDatabase = new(std::nothrow) PlatformDatabase(BASE_PATH);
-       IF_FAIL_RETURN_TAG(__systemDatabase, false, _E, "%s", CTX_ERROR_STR(E_NO_MEM));
+       __systemDatabase = new PlatformDatabase(BASE_PATH);
 
        if (!__systemDatabase->open()) {
                _E("DB open failed");
@@ -51,8 +50,7 @@ bool DatabaseManager::openUser(uid_t uid)
                closeUser();
        }
 
-       __userDatabase = new(std::nothrow) PlatformDatabase(BASE_PATH, uid);
-       IF_FAIL_RETURN_TAG(__userDatabase, false, _E, "%s", CTX_ERROR_STR(E_NO_MEM));
+       __userDatabase = new PlatformDatabase(BASE_PATH, uid);
 
        if (!__userDatabase->open()) {
                _E("DB open failed");
index edb205f..252bcfa 100644 (file)
@@ -88,13 +88,8 @@ bool SchemaLoader::load()
                result = false;
        }
 
-       try {
-               if (result && !__loadSchemaDir(__getSchemaDir())) {
-                       _W("Schema loading failed");
-                       result = false;
-               }
-       } catch (std::regex_error& e) {
-               _E("%s", e.what());
+       if (result && !__loadSchemaDir(__getSchemaDir())) {
+               _W("Schema loading failed");
                result = false;
        }
 
@@ -238,12 +233,7 @@ SchemaChecker* SchemaLoader::__getSchemaChecker()
        if (__schemaChecker)
                return __schemaChecker;
 
-       try {
-               __schemaChecker = new SchemaChecker;
-       } catch (std::exception& e) {
-               _E("Exception: %s", e.what());
-               return NULL;
-       }
+       __schemaChecker = new SchemaChecker;
 
        return __schemaChecker;
 }
@@ -291,7 +281,7 @@ void SchemaLoader::__insertMetadata(Schema& schema)
                        schema.uri.c_str(), columns.c_str(), schema.retention, schema.limit,
                        readPrivil.c_str(), writePrivil.c_str(), schema.uri.c_str());
        if (length <= 0) {
-               _E("Memory allocation failed");
+               _E_ALLOC;
                return;
        }
 
@@ -303,7 +293,7 @@ void SchemaLoader::__insertMetadata(Schema& schema)
                        readPrivil.c_str(), writePrivil.c_str());
        if (length <= 0) {
                g_free(updateSql);
-               _E("Memory allocation failed");
+               _E_ALLOC;
                return;
        }
 
index 1c3b900..3ee0012 100644 (file)
@@ -81,9 +81,7 @@ Store* StoreManager::__createStore(Database& database, std::list<Store*>& stores
        _D("Read: %s", readPrivil.c_str());
        _D("Write: %s", writePrivil.c_str());
 
-       StoreType* store = new(std::nothrow) StoreType();
-       IF_FAIL_RETURN_TAG(store, NULL, _E, "Memory allocation failed");
-
+       StoreType* store = new StoreType();
        store->metadata.uri = uri;
        store->metadata.columns = columns;
        store->metadata.retention= static_cast<unsigned int>(retention);