Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
make Failure throw more consistently
  • Loading branch information
moritz committed Mar 25, 2012
1 parent a4c78fb commit 06b4eca
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/Failure.pm
Expand Up @@ -23,14 +23,16 @@ my class Failure {
}
multi method Bool(Failure:D:) { $!handled = 1; Bool::False; }

method Int(Failure:D:) { $!handled ?? 0 !! $!exception.throw; }
method Num(Failure:D:) { $!handled ?? 0e0 !! $!exception.throw; }
multi method Str(Failure:D:) { $!handled ?? '' !! $!exception.throw; }
method Int(Failure:D:) { $!handled ?? 0 !! $!exception.throw; }
method Num(Failure:D:) { $!handled ?? 0e0 !! $!exception.throw; }
method Numeric(Failure:D:) { $!handled ?? 0e0 !! $!exception.throw; }
multi method Str(Failure:D:) { $!handled ?? '' !! $!exception.throw; }
multi method gist(Failure:D:) { $!handled ?? $.perl !! $!exception.throw; }

Failure.^add_fallback(
-> $, $ { True },
method ($name) {
die $!exception;
$!exception.throw;
}
);
}
Expand Down

0 comments on commit 06b4eca

Please sign in to comment.