From 83cc6e7145dbe9fd2b087a9bf4520334987f7fbf Mon Sep 17 00:00:00 2001 From: Leon Timmermans Date: Tue, 13 Jun 2023 15:06:48 +0200 Subject: [PATCH] Add X::Temporal::OutOfRange (#5272) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X::Temporal is documented as «A common exception type for all errors related to DateTime or Date», however when an invalid date is given an X::OutOfRange is thrown instead. This adds a X::Temporal::OutOfRange that is both, to satisfy the documented requirements. --- src/core.c/Dateish.pm6 | 2 +- src/core.c/Exception.pm6 | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core.c/Dateish.pm6 b/src/core.c/Dateish.pm6 index 72b862cdd7b..4e4e61d71d5 100644 --- a/src/core.c/Dateish.pm6 +++ b/src/core.c/Dateish.pm6 @@ -49,7 +49,7 @@ my role Dateish { # shortcut for out of range throwing method !oor($what, $got, $range) { - X::OutOfRange.new(:$what, :$got, :$range).throw + X::Temporal::OutOfRange.new(:$what, :$got, :$range).throw } # shortcut for invalid format throwing diff --git a/src/core.c/Exception.pm6 b/src/core.c/Exception.pm6 index 78673781fd0..0a8b7f1b832 100644 --- a/src/core.c/Exception.pm6 +++ b/src/core.c/Exception.pm6 @@ -2968,6 +2968,9 @@ my class X::DateTime::InvalidDeltaUnit does X::Temporal { "Cannot use unit $.unit with Date.delta"; } } +my class X::Temporal::OutOfRange is X::OutOfRange does X::Temporal { +} + my class X::Eval::NoSuchLang is Exception { has $.lang;