Skip to content

Commit

Permalink
Alter arg type for error message to be enum category
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Jul 17, 2024
1 parent 7941a36 commit d614e02
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
18 changes: 10 additions & 8 deletions src/EnergyPlus/UtilityRoutines.cc
Original file line number Diff line number Diff line change
Expand Up @@ -866,18 +866,19 @@ bool env_var_on(std::string const &env_var_str)
return ((!env_var_str.empty()) && is_any_of(env_var_str[0], "YyTt"));
}

void emitErrorMessage(EnergyPlusData &state, int idOne, std::string const &msg, bool shouldFatal)
void emitErrorMessage(EnergyPlusData &state, [[maybe_unused]] ErrorMessageCategory category, std::string const &msg, bool shouldFatal)
{
(void)idOne;
if (!shouldFatal) {
ShowSevereError(state, msg);
} else { // should fatal
ShowFatalError(state, msg);
}
}
void emitErrorMessages(EnergyPlusData &state, int idOne, std::initializer_list<std::string> const &msgs, bool shouldFatal)
void emitErrorMessages(EnergyPlusData &state,
[[maybe_unused]] ErrorMessageCategory category,
std::initializer_list<std::string> const &msgs,
bool shouldFatal)
{
(void)idOne;
for (auto msg = msgs.begin(); msg != msgs.end(); ++msg) {
if (msg == msgs.begin()) {
ShowSevereError(state, *msg);
Expand All @@ -888,18 +889,19 @@ void emitErrorMessages(EnergyPlusData &state, int idOne, std::initializer_list<s
}
}
}
void emitWarningMessage(EnergyPlusData &state, int idOne, std::string const &msg, bool const countAsError)
void emitWarningMessage(EnergyPlusData &state, [[maybe_unused]] ErrorMessageCategory category, std::string const &msg, bool const countAsError)
{
(void)idOne;
if (countAsError) { // ideally this path goes away and we just have distinct warnings and errors
ShowWarningError(state, msg);
} else {
ShowWarningMessage(state, msg);
}
}
void emitWarningMessages(EnergyPlusData &state, int idOne, std::initializer_list<std::string> const &msgs, bool const countAsError)
void emitWarningMessages(EnergyPlusData &state,
[[maybe_unused]] ErrorMessageCategory category,
std::initializer_list<std::string> const &msgs,
bool const countAsError)
{
(void)idOne;
for (auto msg = msgs.begin(); msg != msgs.end(); ++msg) {
if (msg == msgs.begin()) {
if (countAsError) { // ideally this path goes away and we just have distinct warnings and errors
Expand Down
32 changes: 28 additions & 4 deletions src/EnergyPlus/UtilityRoutines.hh
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,34 @@ bool env_var_on(std::string const &env_var_str);

using OptionalOutputFileRef = std::optional<std::reference_wrapper<EnergyPlus::InputOutputFile>>;

void emitErrorMessage(EnergyPlusData &state, int idOne, std::string const &msg, bool shouldFatal);
void emitErrorMessages(EnergyPlusData &state, int idOne, std::initializer_list<std::string> const &msgs, bool shouldFatal);
void emitWarningMessage(EnergyPlusData &state, int idOne, std::string const &msg, bool countAsError = false);
void emitWarningMessages(EnergyPlusData &state, int idOne, std::initializer_list<std::string> const &msgs, bool countAsError = false);
enum class ErrorMessageCategory
{
Invalid = -1,
Unclassified,
Input_invalid,
Input_field_not_found,
Input_field_blank,
Input_object_not_found,
Input_cannot_find_object,
Input_topology_problem,
Input_unused,
Input_fatal,
Runtime_general,
Runtime_flow_out_of_range,
Runtime_temp_out_of_range,
Runtime_airflow_network,
Fatal_general,
Developer_general,
Developer_invalid_index,
Num
};
void emitErrorMessage(EnergyPlusData &state, ErrorMessageCategory category, std::string const &msg, bool shouldFatal);
void emitErrorMessages(EnergyPlusData &state, ErrorMessageCategory category, std::initializer_list<std::string> const &msgs, bool shouldFatal);
void emitWarningMessage(EnergyPlusData &state, ErrorMessageCategory category, std::string const &msg, bool countAsError = false);
void emitWarningMessages(EnergyPlusData &state,
ErrorMessageCategory category,
std::initializer_list<std::string> const &msgs,
bool countAsError = false);

void ShowFatalError(EnergyPlusData &state, std::string const &ErrorMessage, OptionalOutputFileRef OutUnit1 = {}, OptionalOutputFileRef OutUnit2 = {});

Expand Down

0 comments on commit d614e02

Please sign in to comment.