Skip to content

Commit

Permalink
Wordwrap X::Method::NotFound message
Browse files Browse the repository at this point in the history
Also tweak related Pair.ACCEPTS wording.
  • Loading branch information
lizmat committed Jul 4, 2020
1 parent eb589c0 commit 1b84e03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/core.c/Exception.pm6
Expand Up @@ -210,12 +210,13 @@ my class X::Method::NotFound is Exception {
$message ~= ". Did you mean '%suggestions.keys()'?";
}
elsif +%suggestions > 1 {
$message ~= ". Did you mean any of these?\n { %suggestions.sort(*.value)>>.key.head(4).join("\n ") }\n";
$message ~= ". Did you mean any of these: { %suggestions.sort(*.value)>>.key.head(4).map( { "'$_'" } ).join(", ") }?";
}

$.addendum
?? "$message\n$.addendum"
($.addendum
?? "$message. $.addendum"
!! $message
).naive-word-wrapper
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/core.c/Pair.pm6
Expand Up @@ -64,8 +64,7 @@ my class Pair does Associative {
invocant => $other,
method => $method,
typename => $other.^name,
addendum => "Did you try to smartmatch against a Pair specifically? If so, then the
key of the Pair should be a valid method name, not '$method'."
addendum => "Or did you try to smartmatch against a Pair specifically? If so, then the key of the Pair should be a valid method name, not '$method'."
).throw
)
}
Expand Down

0 comments on commit 1b84e03

Please sign in to comment.