std::string SqliteDb::Select(const std::string& name) {
auto q = std::move(tizen_base::Database::Sql(kGetActionQuery)
.Bind(name));
- auto r = conn_.Exec(q);
- if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to execute select query: "
- << static_cast<const char*>(r);
+ tizen_base::Database::Result r;
+ try {
+ r = conn_.Exec(q);
+ if (!static_cast<bool>(r)) {
+ LOG(ERROR) << "Failed to execute select query: "
+ << static_cast<const char*>(r);
+ return {};
+ }
+ } catch (const tizen_base::DbException& e) {
+ LOG(ERROR) << "Exception occured: " << e.what();
return {};
}
std::vector<std::string> SqliteDb::Select() {
auto q = tizen_base::Database::Sql(kListActionQuery);
- auto r = conn_.Exec(q);
- if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to execute select query: "
- << static_cast<const char*>(r);
+ tizen_base::Database::Result r;
+ try {
+ r = conn_.Exec(q);
+ if (!static_cast<bool>(r)) {
+ LOG(ERROR) << "Failed to execute select query: "
+ << static_cast<const char*>(r);
+ return {};
+ }
+ } catch (const tizen_base::DbException& e) {
+ LOG(ERROR) << "Exception occured: " << e.what();
return {};
}
.Bind(schema.GetPkgId())
.Bind(schema.GetName())
.Bind(schema.GetJsonStr()));
- auto r = conn_.Exec(q);
- if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to insert action schema: " << schema.GetName()
- << ", error: " << static_cast<const char*>(r);
+ tizen_base::Database::Result r;
+ try {
+ r = conn_.Exec(q);
+ if (!static_cast<bool>(r)) {
+ LOG(ERROR) << "Failed to insert action schema: " << schema.GetName()
+ << ", error: " << static_cast<const char*>(r);
+ return false;
+ }
+ } catch (const tizen_base::DbException& e) {
+ LOG(ERROR) << "Exception occurred: " << e.what();
return false;
}
// delete and insert
auto q = std::move(tizen_base::Database::Sql(kDeleteQuery)
.Bind(schema.GetPkgId()));
- auto r = conn_.Exec(q);
- if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to delete action schema from DB: "
- << schema.GetName() << ", error: " << static_cast<const char*>(r);
+ tizen_base::Database::Result r;
+ try {
+ r = conn_.Exec(q);
+ if (!static_cast<bool>(r)) {
+ LOG(ERROR) << "Failed to delete action schema from DB: "
+ << schema.GetName() << ", error: " << static_cast<const char*>(r);
+ return false;
+ }
+ } catch (const tizen_base::DbException& e) {
+ LOG(ERROR) << "Exception occurred: " << e.what();
return false;
}
.Bind(schema.GetName())
.Bind(schema.GetJsonStr()));
- r = conn_.Exec(q);
- if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to update action schema into DB: "
- << schema.GetName() << ", error: " << static_cast<const char*>(r);
+ try {
+ r = conn_.Exec(q);
+ if (!static_cast<bool>(r)) {
+ LOG(ERROR) << "Failed to update action schema into DB: "
+ << schema.GetName() << ", error: " << static_cast<const char*>(r);
+ return false;
+ }
+ } catch (const tizen_base::DbException& e) {
+ LOG(ERROR) << "Exception occurred: " << e.what();
return false;
}
bool SqliteDb::Uninstall(const ActionSchema& schema) {
auto q = std::move(tizen_base::Database::Sql(kDeleteQuery)
.Bind(schema.GetPkgId()));
- auto r = conn_.Exec(q);
- if (!static_cast<bool>(r)) {
- LOG(ERROR) << "Failed to delete action schema: " << schema.GetName()
- << ", error: " << static_cast<const char*>(r);
+ tizen_base::Database::Result r;
+ try {
+ r = conn_.Exec(q);
+ if (!static_cast<bool>(r)) {
+ LOG(ERROR) << "Failed to delete action schema: " << schema.GetName()
+ << ", error: " << static_cast<const char*>(r);
+ return false;
+ }
+ } catch (const tizen_base::DbException& e) {
+ LOG(ERROR) << "Exception occurred: " << e.what();
return false;
}