Skip to content

cleaned up error messages#799

Open
manuschneider wants to merge 2 commits into
masterfrom
error_messages
Open

cleaned up error messages#799
manuschneider wants to merge 2 commits into
masterfrom
error_messages

Conversation

@manuschneider
Copy link
Copy Markdown
Collaborator

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

❌ Patch coverage is 2.40964% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.23%. Comparing base (8cf43a3) to head (5fbe223).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
src/backend/Storage_base.cpp 2.08% 47 Missing ⚠️
src/backend/StorageImplementation.cpp 0.00% 9 Missing ⚠️
src/Symmetry.cpp 0.00% 7 Missing ⚠️
src/RegularNetwork.cpp 0.00% 6 Missing ⚠️
include/Symmetry.hpp 0.00% 1 Missing and 2 partials ⚠️
src/linalg/Lanczos.cpp 0.00% 3 Missing ⚠️
src/stat/histogram.cpp 0.00% 3 Missing ⚠️
src/backend/Tensor_impl.cpp 0.00% 2 Missing ⚠️
src/Bond.cpp 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/backend/StorageImplementation.cpp Outdated
Comment thread src/RegularGncon.cpp
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");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message here is duplicated. same as src/RegularNetwork.cpp

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The networks print out further information to cout, before cytnx_error_msg throws an error and writes to cerr.

Copy link
Copy Markdown
Collaborator

@IvanaGyro IvanaGyro May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

char msg[512];

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;
        }

@manuschneider manuschneider added the Pending check/approval Issue fixed, and need feedback label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Pending check/approval Issue fixed, and need feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants