Skip to content

Commit

Permalink
Implement X::Numeric::CannotConvert exception
Browse files Browse the repository at this point in the history
It's a generic exception to throw when a numeric cannot be
converted to something (gonna use it for Inf -> Int coercion).
Ideally, X::Numeric::Real would be removed and this exception
be used in its place, but there are 6.c-errata tests expecting
X::Numeric::Real to exist, so I left it in as just an empty
subclass of X::Numeric::CannotConvert
  • Loading branch information
zoffixznet committed Oct 4, 2017
1 parent 38186fc commit 2e72652
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/Exception.pm
Expand Up @@ -2404,15 +2404,17 @@ my class X::Import::Positional is Exception {
}
}

my class X::Numeric::Real is Exception {
my class X::Numeric::CannotConvert is Exception {
has $.target;
has $.reason;
has $.source;

method message() {
"Cannot convert $.source to {$.target.^name}: $.reason";
}

}
my class X::Numeric::Real is X::Numeric::CannotConvert {}

my class X::Numeric::DivideByZero is Exception {
has $.using;
Expand Down

0 comments on commit 2e72652

Please sign in to comment.