class X::Str::Numeric is Exception { }

Error thrown (or wrapped in a Failure) when a conversion from string to a number fails.

For example

say +"42 answers";
CATCH { default { put .^name''.Str } };
# OUTPUT: «X::Str::Numeric: Cannot convert string to number: trailing characters after number in '42⏏ answers' (indicated by ⏏)␤»

Methods§

method source§

method source(--> Str:D)

Returns the string that was attempted to convert to a number

method pos§

method pos(--> Int:D)

Gives the position into the string where the parsing failed.

method reason§

method reason(--> Int:D)

Verbal description of the reason why the conversion failed.

Typegraph§

Type relations for X::Str::Numeric
raku-type-graph Numeric Numeric Real Real Real->Numeric Mu Mu Any Any Any->Mu Cool Cool Cool->Any Complex Complex Complex->Numeric Complex->Cool Stringy Stringy Str Str Str->Cool Str->Stringy Allomorph Allomorph Allomorph->Str ComplexStr ComplexStr ComplexStr->Complex ComplexStr->Allomorph Instant Instant Instant->Real Instant->Cool Int Int Int->Real Int->Cool Rational Rational Rational->Real Num Num Num->Real Num->Cool Duration Duration Duration->Real Duration->Cool PromiseStatus PromiseStatus PromiseStatus->Int atomicint atomicint atomicint->Int Bool Bool Bool->Int Order Order Order->Int IntStr IntStr IntStr->Allomorph IntStr->Int int int int->Int Endian Endian Endian->Int Signal Signal Signal->Int NumStr NumStr NumStr->Allomorph NumStr->Num FatRat FatRat FatRat->Cool FatRat->Rational Rat Rat Rat->Cool Rat->Rational

Expand chart above