Skip to content

Commit 1d6d133

Browse files
committed
throw when component type not found in dataset
Signed-off-by: Martijn Govers <Martijn.Govers@Alliander.com>
1 parent 16ea1e3 commit 1d6d133

File tree

1 file changed

+10
-1
lines changed
  • power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp

1 file changed

+10
-1
lines changed

power_grid_model_c/power_grid_model_cpp/include/power_grid_model_cpp/dataset.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
#include "power_grid_model_c/dataset.h"
1414

1515
namespace power_grid_model_cpp {
16+
class ComponentTypeNotFound : public PowerGridError {
17+
public:
18+
ComponentTypeNotFound(std::string const& component)
19+
: PowerGridError{[&]() {
20+
using namespace std::string_literals;
21+
return "ComponentType"s + component + " not found"s;
22+
}()} {}
23+
ComponentTypeNotFound(std::string_view component) : ComponentTypeNotFound{std::string{component}} {}
24+
};
1625

1726
class DatasetInfo {
1827

@@ -51,7 +60,7 @@ class DatasetInfo {
5160
return idx;
5261
}
5362
}
54-
return -1;
63+
throw ComponentTypeNotFound{component};
5564
}
5665

5766
private:

0 commit comments

Comments
 (0)