From: Florian Ragwitz Date: Sat, 28 Mar 2009 13:24:17 +0000 (+0100) Subject: Improve mro merging error messages. X-Git-Tag: 0.10~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b6bdbb4cd4eabccfea0b721257dffee4ca74adbc;p=gitmo%2FClass-C3-XS.git Improve mro merging error messages. This makes them very similar to those produced by Algorithm::C3. This change is similar to b1172053 in blead. --- diff --git a/XS.xs b/XS.xs index db14fd5..94ba2d8 100644 --- a/XS.xs +++ b/XS.xs @@ -231,13 +231,22 @@ __mro_linear_isa_c3(pTHX_ HV* stash, HV* cache, I32 level) /* If we had candidates, but nobody won, then the @ISA hierarchy is not C3-incompatible */ if(!winner) { + SV *errmsg; + I32 i; /* we have to do some cleanup before we croak */ + errmsg = newSVpvf("Inconsistent hierarchy during C3 merge of class '%s':\n\t" + "current merge results [\n", stashname); + for (i = 0; i <= av_len(retval); i++) { + SV **elem = av_fetch(retval, i, 0); + sv_catpvf(errmsg, "\t\t%"SVf",\n", SVfARG(*elem)); + } + sv_catpvf(errmsg, "\t]\n\tmerging failed on '%"SVf"'", SVfARG(cand)); + SvREFCNT_dec(retval); Safefree(heads); - Perl_croak(aTHX_ "Inconsistent hierarchy during C3 merge of class '%s': " - "merging failed on parent '%s'", stashname, SvPV_nolen(cand)); + croak("%"SVf, SVfARG(errmsg)); } } }