Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
typed exception for private method not found
  • Loading branch information
moritz committed May 27, 2012
1 parent 47f26e7 commit decb0a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/core/Exception.pm
Expand Up @@ -42,11 +42,15 @@ my class X::AdHoc is Exception {
my class X::Method::NotFound is Exception {
has $.method;
has $.typename;
has Bool $.private = False;
method message() {
"No such method '$.method' for invocant of type '$.typename'";
$.private
?? "No such private method '$.method' for invocant of type '$.typename'"
!! "No such method '$.method' for invocant of type '$.typename'";
}
}


sub EXCEPTION(|$) {
my Mu $parrot_ex := nqp::shift(pir::perl6_current_args_rpa__P());
my Mu $payload := nqp::atkey($parrot_ex, 'payload');
Expand Down
7 changes: 5 additions & 2 deletions src/core/Mu.pm
Expand Up @@ -268,8 +268,11 @@ my class Mu {
my $meth := $type.HOW.find_private_method($type, $name);
$meth ??
$meth($self, |$c) !!
die("Private method '$name' not found on type " ~ $type.HOW.name($type))

X::Method::NotFound.new(
method => '!' ~ $name,
typename => $type.HOW.name($type),
:private,
).throw;
}

method dispatch:<.^>(Mu \$self: $name, |$c) is rw is hidden_from_backtrace {
Expand Down

0 comments on commit decb0a5

Please sign in to comment.