Skip to content

Commit

Permalink
Streamline X::Str::Sprintf::Directives::BadType
Browse files Browse the repository at this point in the history
- make it handle Mu as a value correctly
- simplify value reporting in case of a type object
  • Loading branch information
lizmat committed Jun 9, 2023
1 parent d3372c8 commit 40aa160
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core.c/Exception.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -2502,11 +2502,18 @@ my class X::Str::Sprintf::Directives::BadType is Exception {
has str $.directive;
has str $.expected;
has str $.format;
has $.value;
has Mu $.value;
method value() {
nqp::istype($!value,List)
?? (' (' ~ Rakudo::Internals.SHORT-STRING($!value[0]) ~ ')')
!! nqp::isconcrete($!value)
?? (' (' ~ Rakudo::Internals.SHORT-STRING($!value) ~ ')')
!! "";
}
method message() {
(($.expected
?? "Directive %$.directive expected a $.expected value, not a $.type ({Rakudo::Internals.SHORT-STRING: $.value[0]})"
!! "Directive %$.directive not applicable for value of type $.type ({Rakudo::Internals.SHORT-STRING: $.value[0]})"
?? "Directive %$.directive expected a $.expected value, not a $.type$.value"
!! "Directive %$.directive not applicable for value of type $.type$.value"
) ~ " in format '$.format'").naive-word-wrapper
}
}
Expand Down

0 comments on commit 40aa160

Please sign in to comment.