Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors gracefully #1954

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/NewUpdateModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Dex.MultipageModal
}
else
{
console.error(Dex.API.app.updateCheckerService.udpateInfo.status)
console.error(Dex.API.app.updateCheckerService.updateInfo.status)
}
}
}
Expand Down
22 changes: 16 additions & 6 deletions src/core/atomicdex/services/price/global.provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,25 +210,34 @@ namespace atomic_dex
{
t_float_50 rate(1);
{
std::shared_lock lock(m_coin_rate_mutex);
rate = t_float_50(m_coin_rate_providers.at(fiat)); ///< Retrieve BTC or KMD rate let's say for USD
if (m_coin_rate_providers.contains(fiat))
{
std::shared_lock lock(m_coin_rate_mutex);
rate = t_float_50(m_coin_rate_providers.at(fiat)); ///< Retrieve BTC or KMD rate let's say for USD
}
}
t_float_50 tmp_current_price = t_float_50(current_price) * rate;
current_price = tmp_current_price.str();
}
else if (fiat != "USD")
{
t_float_50 tmp_current_price = t_float_50(current_price) * m_other_fiats_rates->at("rates").at(fiat).get<double>();
current_price = tmp_current_price.str();
if (m_other_fiats_rates->contains("rates"))
{
t_float_50 tmp_current_price = t_float_50(current_price) * m_other_fiats_rates->at("rates").at(fiat).get<double>();
current_price = tmp_current_price.str();
}
}
}
else
{
//! We use oracle
if (is_this_currency_a_fiat(m_cfg, fiat) && fiat != "USD")
{
t_float_50 tmp_current_price = t_float_50(current_price) * m_other_fiats_rates->at("rates").at(fiat).get<double>();
current_price = tmp_current_price.str();
if (m_other_fiats_rates->contains("rates"))
{
t_float_50 tmp_current_price = t_float_50(current_price) * m_other_fiats_rates->at("rates").at(fiat).get<double>();
current_price = tmp_current_price.str();
}
}

else if (!is_this_currency_a_fiat(m_cfg, fiat) && is_oracle_ready)
Expand Down Expand Up @@ -264,6 +273,7 @@ namespace atomic_dex
SPDLOG_ERROR("Exception caught in get_rate_conversion: {} - fiat: {} - ticker: {}", error.what(), fiat, ticker);
return "0.00";
}
return "0.00";
}

std::string
Expand Down