Skip to content

Commit 854b6af

Browse files
committed
make error msg of Branch checks more clear
1 parent cdd3507 commit 854b6af

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

infra/Branch.hpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,18 @@ class Branch {
102102

103103
/* Checks are used very often */
104104
inline void CheckFrozen(bool expected = true) const {
105-
if (is_frozen_ != expected)
106-
throw std::runtime_error("Branch is frozen");
105+
if (is_frozen_ != expected) {
106+
const std::string prefix = expected ? "un" : "";
107+
const std::string message = "Branch " + config_.GetName() + " is " + prefix + "frozen while the opposite was expected";
108+
throw std::runtime_error(message);
109+
}
107110
}
108111
inline void CheckMutable(bool expected = true) const {
109-
if (is_mutable_ != expected)
110-
throw std::runtime_error("Branch is not mutable");
112+
if (is_mutable_ != expected) {
113+
const std::string prefix = expected ? "im" : "";
114+
const std::string message = "Branch " + config_.GetName() + " is " + prefix + "mutable while the opposite was expected";
115+
throw std::runtime_error(message);
116+
}
111117
}
112118
/**
113119
* @brief Gets variables according to variable names specified in the arguments.

0 commit comments

Comments
 (0)