summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2024-05-30 19:05:52 +0900
committerNobuyoshi Nakada <[email protected]>2024-05-30 19:05:52 +0900
commit949fabe4e9f60428753e280c7fbc22884d3735b8 (patch)
tree7ebbd5850ce23945ef380b940b7b2586bf8d8d6d /error.c
parentbc6860db23b0df3bce09378605a618b677dd6d89 (diff)
[DEBUG] More info when SyntaxError#path changed
Diffstat (limited to 'error.c')
-rw-r--r--error.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/error.c b/error.c
index 6d79f789d2..9890fddcef 100644
--- a/error.c
+++ b/error.c
@@ -2721,8 +2721,16 @@ syntax_error_with_path(VALUE exc, VALUE path, VALUE *mesg, rb_encoding *enc)
else {
VALUE old_path = rb_attr_get(exc, id_i_path);
if (old_path != path) {
- rb_raise(rb_eArgError, "SyntaxError#path changed: %+"PRIsVALUE"->%+"PRIsVALUE,
- old_path, path);
+ if (rb_str_equal(path, old_path)) {
+ rb_raise(rb_eArgError, "SyntaxError#path changed: %+"PRIsVALUE" (%p->%p)",
+ old_path, (void *)old_path, (void *)path);
+ }
+ else {
+ rb_raise(rb_eArgError, "SyntaxError#path changed: %+"PRIsVALUE"(%s%s)->%+"PRIsVALUE"(%s)",
+ old_path, rb_enc_name(rb_enc_get(old_path)),
+ (FL_TEST(old_path, RSTRING_FSTR) ? ":FSTR" : ""),
+ path, rb_enc_name(rb_enc_get(path)));
+ }
}
VALUE s = *mesg = rb_attr_get(exc, idMesg);
if (RSTRING_LEN(s) > 0 && *(RSTRING_END(s)-1) != '\n')