cleaned up error messages#799
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #799 +/- ##
=======================================
Coverage 36.22% 36.23%
=======================================
Files 214 214
Lines 33128 33123 -5
Branches 13171 13168 -3
=======================================
Hits 12002 12002
+ Misses 19183 19178 -5
Partials 1943 1943 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| cout << " " << TN_names[i] << endl; | ||
| } | ||
| cytnx_error_msg(true, "%s", "\n"); | ||
| cytnx_error_msg(true, "[ERROR] TNs appeared in ORDER line, but are not defined.%s", "\n"); |
There was a problem hiding this comment.
The error message here is duplicated. same as src/RegularNetwork.cpp
There was a problem hiding this comment.
The networks print out further information to cout, before cytnx_error_msg throws an error and writes to cerr.
There was a problem hiding this comment.
Yes, that is what I meant. The current change will duplicate the message was printed to stdout. There are two options for cleaning this up.
option 1: compose the error message before outputting
if (!TN_names.empty()) {
std::ostringstream oss;
oss << "Following TNs appeared in ORDER line, but are not defined.\n";
for (const auto& name : TN_names) {
oss << " " << name << '\n';
}
const std::string msg = oss.str();
// Works with the current macro, but unsafe if msg.size() >= about 512.
cytnx_error_msg(true, "%s", msg.c_str());
}However, notice that the length of message will be limited by the current implementation of cytnx_error_msg. The max length of the composed string is 512. See:
Line 38 in 14ef89a
option2: just output the whole message to stderr and let cytnx_error_msg pass "\n" only before updating the implementation of cytnx_error_msg
cerr << "[ERROR] Following TNs appeared in ORDER line, but is not defined." << endl;
for (const auto& name : TN_names) {
cerr << " " << name << endl;
}
No description provided.