nothrow only guarantee that new operation will not throw exception.
Using nothrow cannot prevent exceptions thrown by a constructor.
Change-Id: I1cafbe6c582f64abb007c12dcafd79fac569ffcb
Signed-off-by: hyunho <hhstark.kang@samsung.com>
char* provider_id;
int type;
int complication_id;
- bundle_raw* raw = NULL;
+ bundle_raw* raw = nullptr;
g_variant_get(parameters, "(&sii&s)", &provider_id, &type,
&complication_id, &raw);
return;
}
- if (raw == nullptr) {
+ if (strlen(reinterpret_cast<char*>(raw)) == 0) {
LOGW("Empty data !!");
return;
}
- last_data_.reset(new (std::nothrow) Bundle(
- string(reinterpret_cast<char*>(raw))));
- if (last_data_.get() == nullptr) {
- LOGE("Out of memmory, create bundle fail");
+ try {
+ last_data_.reset(new Bundle(string(reinterpret_cast<char*>(raw))));
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return;
}
+
LOGI("data: %s, %d, cur_type :%d", provider_id, complication_id, cur_type_);
parent_->OnDataUpdated(std::string(provider_id), cur_type_, last_data_);
}
impl_->context_data_.get());
if (ret != WATCHFACE_COMPLICATION_ERROR_NONE)
return ret;
- Bundle* new_ctx = new (std::nothrow) Bundle(
- (impl_->context_data_.get())->GetHandle());
- if (new_ctx == nullptr)
+
+ try {
+ Bundle* new_ctx = new Bundle(impl_->context_data_->GetHandle());
+ impl_->last_context_data_.reset(new_ctx);
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
- impl_->last_context_data_.reset(new_ctx);
+ }
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
}
int Complication::Impl::AddCandidate(std::string provider_id, int type) {
- unique_ptr<Bundle> data = unique_ptr<Bundle>(new (std::nothrow) Bundle());
- if (data.get() == nullptr) {
- LOGE("Out of memory");
+ unique_ptr<Bundle> data;
+ try {
+ data = unique_ptr<Bundle>(new Bundle());
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
cur_provider_id_.c_str());
if (context_data_ == nullptr)
return WATCHFACE_COMPLICATION_ERROR_NONE;
- Bundle* ctx = new (std::nothrow) Bundle(context_data_.get()->GetHandle());
- if (ctx == nullptr) {
- LOGE("Out of memory");
+
+ try {
+ Bundle* ctx = new Bundle(context_data_->GetHandle());
+ last_context_data_.reset(ctx);
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- last_context_data_.reset(ctx);
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
goto out;
}
- default_data = std::unique_ptr<Bundle>(
- new (std::nothrow) Bundle(std::string(raw_data)));
- if (default_data.get() == nullptr) {
- LOGE("fail to create default data");
+ try {
+ default_data = std::unique_ptr<Bundle>(new Bundle(std::string(raw_data)));
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
goto out;
}
+
util::ConvertPathToAppPath(
provider_app_id.c_str(), default_data.get()->GetHandle());
}
LOGI("Empty context");
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
- Bundle* ctx = new (std::nothrow) Bundle(
- (impl_->context_data_.get())->GetHandle());
- if (ctx == nullptr) {
- LOGE("Out of memory");
+
+ try {
+ Bundle* ctx = new Bundle(impl_->context_data_->GetHandle());
+ impl_->last_context_data_.reset(ctx);
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- impl_->last_context_data_.reset(ctx);
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
unique_ptr<Bundle> ctx_ptr;
std::string ctx_str = std::string(context);
if (!ctx_str.empty()) {
- ctx_ptr = std::unique_ptr<Bundle>(new (std::nothrow) Bundle(ctx_str));
- if (ctx_ptr.get() == nullptr) {
- LOGE("Fail to create bundle");
+ try {
+ ctx_ptr = std::unique_ptr<Bundle>(new Bundle(ctx_str));
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return;
}
}
if (sqlite3_step(stmt) == SQLITE_ROW) {
raw_data = reinterpret_cast<const char*>(sqlite3_column_text(stmt, 0));
- context_data = std::unique_ptr<Bundle>(
- new (std::nothrow) Bundle(std::string(raw_data)));
- if (context_data.get() == nullptr) {
- LOGE("Out of memory");
+ try {
+ context_data = std::unique_ptr<Bundle>(new Bundle(std::string(raw_data)));
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
sqlite3_finalize(stmt);
return nullptr;
}
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
- Bundle* ctx = new (std::nothrow) Bundle(
- (impl_->context_data_.get())->GetHandle());
- if (ctx == nullptr) {
- LOGE("Out of memory");
+ try {
+ Bundle* ctx = new Bundle(impl_->context_data_->GetHandle());
+ impl_->last_context_data_.reset(ctx);
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- impl_->last_context_data_.reset(ctx);
return WATCHFACE_COMPLICATION_ERROR_NONE;
}
if (data == nullptr)
continue;
- Bundle* new_data = new (std::nothrow) Bundle(data);
- if (new_data == nullptr) {
- LOGE("Out of memory");
+ try {
+ new_list.emplace_back(new Bundle(data));
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- new_list.emplace_back(move(new_data));
}
if (ec->IsExist(edit_id)) {
if (cb == nullptr)
return WATCHFACE_COMPLICATION_ERROR_INVALID_PARAMETER;
- if (__container == nullptr)
- __container = new (std::nothrow) EditablesContainerStub();
+ if (__container == nullptr) {
+ try {
+ __container = new EditablesContainerStub();
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
+ return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
+ }
+ }
if (__container == nullptr) {
LOGE("Out of memory");
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
if (__stub == nullptr) {
- __stub = std::unique_ptr<EditablesEditorStub>(
- new (std::nothrow) EditablesEditorStub());
- if (__stub == nullptr) {
- LOGE("Out of memory");
+ try {
+ __stub = std::unique_ptr<EditablesEditorStub>(new EditablesEditorStub());
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
}
int re = WATCHFACE_COMPLICATION_ERROR_NONE;
IEditable* ed = static_cast<IEditable*>(handle);
if (new_context) {
- std::unique_ptr<Bundle> b(new (std::nothrow) Bundle(new_context));
- if (b.get() == nullptr) {
- LOGE("Out of memory");
+ try {
+ std::unique_ptr<Bundle> b(new Bundle(new_context));
+ re = ed->SetContext(std::move(b));
+ } catch (const std::exception& e) {
+ LOGE("Exception occurred : %s", e.what());
return WATCHFACE_COMPLICATION_ERROR_OUT_OF_MEMORY;
}
- re = ed->SetContext(std::move(b));
} else {
re = ed->SetContext(std::unique_ptr<Bundle>{});
}