Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
typed exception from failed .+ dispatch
also prepare exception for returning form exhausted routine
  • Loading branch information
moritz committed May 27, 2012
1 parent e756635 commit 47f26e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -659,6 +659,11 @@ my class X::ControlFlow::Return is X::ControlFlow {
method enclosing() { 'Routine' }
method message() { 'Attempt to return outside of any Routine' }
}
my class X::ControlFlow::Routine::Exhausted is X::ControlFlow {
method illegal() { 'return' }
method enclosing() { 'not a Routine' }
method message() { 'Attempt to return from exhausted Routine' }
}

my class X::TypeCheck is Exception {
has $.operation;
Expand Down
7 changes: 5 additions & 2 deletions src/core/Mu.pm
@@ -1,4 +1,5 @@
my class X::Constructor::Positional { ... }
my class X::Method::NotFound { ... }

my class Mu {
proto method ACCEPTS(|$) { * }
Expand Down Expand Up @@ -288,8 +289,10 @@ my class Mu {
method dispatch:<.+>(Mu \$self: $name, |$c) {
my @result := $self.dispatch:<.*>($name, |$c);
if @result.elems == 0 {
die "Method '$name' not found for invocant of type '" ~
$self.WHAT.perl ~ "'";
X::Method::NotFound.new(
method => $name,
typename => $self.^name,
).throw;
}
@result
}
Expand Down

0 comments on commit 47f26e7

Please sign in to comment.