Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make X::TypeCheck a little more informative
by showing the actual value passed if possible, truncated if too long
  • Loading branch information
lizmat committed Feb 18, 2016
1 parent e3b1dd3 commit 9983c2c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/Exception.pm
Expand Up @@ -1810,8 +1810,20 @@ my class X::TypeCheck is Exception {
has $.operation;
has $.got is default(Nil);
has $.expected is default(Nil);
method gotn() { (try $!got.^name eq $!expected.^name ?? $!got.perl !! $!got.^name) // "?" }
method expectedn() { (try $!got.^name eq $!expected.^name ?? $!expected.perl !! $!expected.^name) // "?" }
method gotn() {
my $perl = (try $!got.perl) // "?";
$perl = "$perl.substr(0,21)..." if $perl.chars > 24;
(try $!got.^name eq $!expected.^name
?? $perl
!! "$!got.^name() ($perl)"
) // "?"
}
method expectedn() {
(try $!got.^name eq $!expected.^name
?? $!expected.perl
!! $!expected.^name
) // "?"
}
method priors() {
my $prior = do if nqp::isconcrete($!got) && $!got ~~ Failure {
"Earlier failure:\n " ~ $!got.mess ~ "\nFinal error:\n ";
Expand Down

0 comments on commit 9983c2c

Please sign in to comment.