Raise std::invalid_argument exception instead of dying.
Thanks for the review ;)
* @param speed_per_state list of powers for this processor (default power is at index 0)
*/
Host* set_pstate_speed(const std::vector<double>& speed_per_state);
- /** @brief Set the CPU's speed (string version) */
+ /**
+ * @brief Set the CPU's speed (string version)
+ *
+ * @throw std::invalid_argument if speed format is incorrect.
+ */
Host* set_pstate_speed(const std::vector<std::string>& speed_per_state);
/** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
* @param value New latency value (in s)
*/
Link* set_latency(double value);
- /** @brief Set latency (string version) */
+ /**
+ * @brief Set latency (string version)
+ *
+ * @throw std::invalid_argument if latency format is incorrect.
+ */
Link* set_latency(const std::string& value);
/** @brief Describes how the link is shared between flows */
* @param speed_per_state Vector of CPU's speeds
*/
s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate);
- /** @brief Create a Host (string version) */
+ /**
+ * @brief Create a Host (string version)
+ *
+ * @throw std::invalid_argument if speed format is incorrect.
+ */
s4u::Host* create_host(const std::string& name, const std::vector<std::string>& speed_per_pstate);
/**
* @param name Link name
* @param bandwidths Link's speed (vector for wifi links)
* @param policy Link sharing policy
+ * @throw std::invalid_argument if bandwidth format is incorrect.
*/
s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
Link::SharingPolicy policy = Link::SharingPolicy::SHARED);
double speed = xbt_parse_get_speed("", 0, speed_str.c_str(), nullptr, "");
speed_list.push_back(speed);
} catch (const simgrid::ParseError&) {
- xbt_die("Host: Impossible to set_pstate_speed, invalid speed %s", speed_str.c_str());
+ throw std::invalid_argument(std::string("Invalid speed value: ") + speed_str);
}
}
return speed_list;
try {
d_value = xbt_parse_get_time("", 0, value.c_str(), nullptr, "");
} catch (const simgrid::ParseError&) {
- xbt_die("Link: Impossible to latency, invalid value %s", value.c_str());
+ throw std::invalid_argument(std::string("Impossible to set latency for link: ") + get_name() +
+ std::string(". Invalid value: ") + value);
}
return set_latency(d_value);
}
double speed = xbt_parse_get_bandwidth("", 0, speed_str.c_str(), nullptr, "");
bw.push_back(speed);
} catch (const simgrid::ParseError&) {
- xbt_die("Link: Impossible to create_link, invalid bandwidth %s", speed_str.c_str());
+ throw std::invalid_argument(std::string("Impossible to create link: ") + name +
+ std::string(". Invalid bandwidth: ") + speed_str);
}
}
return create_link(name, bw, policy);