- if (tmp.size() != this->levels_) {
- surf_parse_error("Fat trees are defined by the levels number and 3 vectors"
- ", see the documentation for more information");
- }
- for (size_t i = 0; i < tmp.size(); i++) {
- this->lowerLevelPortsNumber_.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s"));
+ surf_parse_assert(tmp.size() == this->levels_, std::string("You specified ") + std::to_string(this->levels_) +
+ " levels but the port count vector (the third one) contains " +
+ std::to_string(tmp.size()) + " levels.");
+ for (std::string const& port : tmp) {
+ try {
+ this->num_port_lower_level_.push_back(std::stoi(port));
+ } catch (const std::invalid_argument&) {
+ throw std::invalid_argument(std::string("Invalid lower level port number:") + port);
+ }