Skip to content

Commit bfc58a1

Browse files
Merge pull request #845 from PowerGridModel/feature/adding-not-observable-error-when-no-voltage-sensor-present
Adding message to `NotObservableError` when no voltage sensor present
2 parents 7af69ee + edf220a commit bfc58a1

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/common/exception.hpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ class SparseMatrixError : public PowerGridError {
112112

113113
class NotObservableError : public PowerGridError {
114114
public:
115-
NotObservableError() { append_msg("Not enough measurements available for state estimation.\n"); }
115+
NotObservableError(std::string const& msg = "") {
116+
append_msg("Not enough measurements available for state estimation.\n");
117+
if (!msg.empty()) {
118+
append_msg(msg + "\n");
119+
}
120+
}
116121
};
117122

118123
class IterationDiverge : public PowerGridError {

power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ inline void necessary_observability_check(MeasuredValues<sym> const& measured_va
6868

6969
auto const [n_voltage_sensor, n_voltage_phasor_sensor] = detail::count_voltage_sensors(n_bus, measured_values);
7070
if (n_voltage_sensor < 1) {
71-
throw NotObservableError{};
71+
throw NotObservableError{"no voltage sensor found"};
7272
}
7373

7474
Idx const n_injection_sensor = detail::count_bus_injection_sensors(n_bus, measured_values);

0 commit comments

Comments
 (0)