Skip to content

feat: improve formatting of error messages from C#2515

Merged
krlmlr merged 13 commits intomainfrom
better
Jan 24, 2026
Merged

feat: improve formatting of error messages from C#2515
krlmlr merged 13 commits intomainfrom
better

Conversation

@maelle
Copy link
Contributor

@maelle maelle commented Jan 6, 2026

Fix #2202

One thing we might consider adding, is a period at the end of the message if it's not already there.

@szhorvat
Copy link
Member

szhorvat commented Jan 6, 2026

One thing we might consider adding, is a period at the end of the message if it's not already there.

I've added punctuation at the end of most messages in the C core now, but a few are still left out. This is a nice-to-have aesthetic feature, it's not an absolute must unless you want to append extra text at the end of the message. We do correct for missing punctuation in both the Python and Mathematica interfaces.

@szhorvat
Copy link
Member

szhorvat commented Jan 6, 2026

One thing we might consider adding, is a period at the end of the message if it's not already there.

Isn't this already there with maybe_add_puctuation?

LGTM, but I didn't test.

Co-authored-by: Szabolcs Horvát <szhorvat@gmail.com>
@maelle
Copy link
Contributor Author

maelle commented Jan 13, 2026

Thank you @szhorvat @schochastics!

@maelle
Copy link
Contributor Author

maelle commented Jan 13, 2026

@szhorvat with your change the path wasn't simplified any longer, does my fix make any sense?

@szhorvat
Copy link
Member

I'm sorry, I can't seem to see your fix, but I'm in a rush and may be missing something. I believe my mistake is that 1 needs to be subtracted from prefix_len to account for the null terminator. I'll comment with a fix, and will return in a couple fo days when I can dedicate time to this.

* build procedure, namely on the directory that the compiler is invoked from. */
static inline const char* simplify_file_path(const char *file) {
const char prefix[] = "vendor/cigraph/src/";
const size_t prefix_len = sizeof(prefix) / sizeof(prefix[0]);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const size_t prefix_len = sizeof(prefix) / sizeof(prefix[0]);
const size_t prefix_len = sizeof(prefix) / sizeof(prefix[0]) - 1;

@maelle
Copy link
Contributor Author

maelle commented Jan 13, 2026

oops my push hadn't worked... anyhow thanks a ton!!

Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

@copilot: Address review. Also create a new test for just the functionality: a function that we can call from R that throws an error with file-line information, and a corresponding test.

expect_snapshot(error = TRUE, {
arpack(f, options = list(nev = 2, ncv = 4), sym = TRUE)
})
expect_snapshot(
Copy link
Contributor

Choose a reason for hiding this comment

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

Create a new wrapper for expect_snapshot(error = TRUE, transform = ...) . Use where applicable.

Copy link
Contributor

Copilot AI commented Jan 22, 2026

@krlmlr I've opened a new pull request, #2522, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits January 24, 2026 10:37
…function (#2522)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: Kirill Müller <krlmlr@users.noreply.github.com>
Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

@copilot: Use expect_snapshot_igraph_error() everywhere instead of expect_snapshot(error = TRUE), except in tests/testthat/test-error-formatting.R . Search in tests/testthat for a literal expect_snapshot(error = TRUE first to find many occurrences, then search for error = TRUE and look for a surrounding expect_snapshot() call. Ensure all calls are transformed, except the one where we add a comment to explain why we keep the test. Move Rx_igraph_test_error_with_source() into a separate C file to keep the line number in the error message stable.

Copy link
Contributor

Copilot AI commented Jan 24, 2026

@krlmlr I've opened a new pull request, #2528, to work on those changes. Once the pull request is ready, I'll request review from you.

…raph_error()` (#2528)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
@krlmlr
Copy link
Contributor

krlmlr commented Jan 24, 2026

@copilot: Change expect_snapshot_igraph_error() to also scrub the file name. Update snapshots.

Copy link
Contributor

Copilot AI commented Jan 24, 2026

@krlmlr I've opened a new pull request, #2537, to work on those changes. Once the pull request is ready, I'll request review from you.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Copy link
Contributor

@krlmlr krlmlr left a comment

Choose a reason for hiding this comment

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

@copilot: Let's do one more round.

Error in `sample_degseq()`:
! At vendor/cigraph/src/games/degree_sequence_vl/gengraph_mr-connected.cpp:<linenumber> : Cannot make a connected graph from the given degree sequence. Invalid value
! Cannot make a connected graph from the given degree sequence. Invalid value
Source: games/degree_sequence_vl/gengraph_mr-connected.cpp:<linenumber>
Copy link
Contributor

Choose a reason for hiding this comment

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

Scrub here too.

Warning in `connect_neighborhood_impl()`:
At vendor/cigraph/src/operators/connect_neighborhood.c:85 : Order smaller than two, graph will be unchanged.
Order smaller than two, graph will be unchanged.
Source: operators/connect_neighborhood.c:85
Copy link
Contributor

Choose a reason for hiding this comment

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

And here.

Condition
Error in `hrg_sample_impl()`:
! At vendor/cigraph/src/hrg/hrg_types.cc:xx : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it.
! At <file>:<line> : Assertion failed: n >= 0. This is an unexpected igraph error; please report this as a bug, along with the steps to reproduce it.
Copy link
Contributor

Choose a reason for hiding this comment

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

These and similar errors hint at an error in the wrapping code. Fix.

Copy link
Contributor

Copilot AI commented Jan 24, 2026

@krlmlr I've opened a new pull request, #2538, to work on those changes. Once the pull request is ready, I'll request review from you.

@krlmlr krlmlr merged commit c4a2c33 into main Jan 24, 2026
1 check passed
@krlmlr krlmlr deleted the better branch January 24, 2026 17:22
@krlmlr
Copy link
Contributor

krlmlr commented Jan 24, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warning

5 participants