From 672dce501aa8b7a5a3188bde223f42ee20194d2e Mon Sep 17 00:00:00 2001 From: Bruno Donassolo Date: Fri, 2 Apr 2021 12:01:09 +0200 Subject: [PATCH] Fix error handling. Raise std::invalid_argument exception instead of dying. Thanks for the review ;) --- include/simgrid/s4u/Host.hpp | 6 +++++- include/simgrid/s4u/Link.hpp | 6 +++++- include/simgrid/s4u/NetZone.hpp | 7 ++++++- src/s4u/s4u_Host.cpp | 2 +- src/s4u/s4u_Link.cpp | 3 ++- src/s4u/s4u_Netzone.cpp | 3 ++- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 3fc3b0cd37..834944e8f4 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -119,7 +119,11 @@ public: * @param speed_per_state list of powers for this processor (default power is at index 0) */ Host* set_pstate_speed(const std::vector& 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& speed_per_state); /** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account. diff --git a/include/simgrid/s4u/Link.hpp b/include/simgrid/s4u/Link.hpp index 05808a12f9..8ee0cf9f86 100644 --- a/include/simgrid/s4u/Link.hpp +++ b/include/simgrid/s4u/Link.hpp @@ -64,7 +64,11 @@ public: * @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 */ diff --git a/include/simgrid/s4u/NetZone.hpp b/include/simgrid/s4u/NetZone.hpp index 4d005162bf..1fc5dc81d8 100644 --- a/include/simgrid/s4u/NetZone.hpp +++ b/include/simgrid/s4u/NetZone.hpp @@ -85,7 +85,11 @@ public: * @param speed_per_state Vector of CPU's speeds */ s4u::Host* create_host(const std::string& name, const std::vector& 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& speed_per_pstate); /** @@ -94,6 +98,7 @@ public: * @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& bandwidths, Link::SharingPolicy policy = Link::SharingPolicy::SHARED); diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index fdaf2cad78..08234c46b1 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -280,7 +280,7 @@ std::vector Host::convert_pstate_speed_vector(const std::vector