Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
typed exceptions for temp and let on non-containers
  • Loading branch information
moritz committed May 27, 2012
1 parent a4c09d1 commit 493adbf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/core/Exception.pm
Expand Up @@ -707,6 +707,14 @@ my class X::NoDispatcher is Exception {
}
}

my class X::Localizer::NoContainer is Exception {
has $.localizer;
method message() {
"Can only use '$.localizer' on a container";
}
}


{
my %c_ex;
%c_ex{'X::TypeCheck::Binding'} := sub ($got, $expected) is hidden_from_backtrace {
Expand Down
4 changes: 2 additions & 2 deletions src/core/operators.pm
Expand Up @@ -201,7 +201,7 @@ sub prefix:<temp>(\$cont) is rw {
nqp::push($temp_restore, my %h = $cont);
}
else {
die "Can only use 'temp' on a container";
X::Localizer::NoContainer.new(localizer => 'temp').throw;
}
$cont
}
Expand All @@ -221,7 +221,7 @@ sub prefix:<let>(\$cont) is rw {
nqp::push($let_restore, my %h = $cont);
}
else {
die "Can only use 'let' on a container";
X::Localizer::NoContainer.new(localizer => 'let').throw;
}
$cont
}
Expand Down

0 comments on commit 493adbf

Please sign in to comment.