- char* idleMsg = bprintf("Invalid idle power value for link%s", this->link_->get_cname());
- char* busyMsg = bprintf("Invalid busy power value for %s", this->link_->get_cname());
-
- idle_ = xbt_str_parse_double((current_power_values.at(0)).c_str(), idleMsg);
- busy_ = xbt_str_parse_double((current_power_values.at(1)).c_str(), busyMsg);
+ try {
+ idle_ = std::stod(current_power_values.front());
+ } catch (const std::invalid_argument&) {
+ throw std::invalid_argument(std::string("Invalid idle power value for link ") + this->link_->get_cname());
+ }