Skip to content

Commit

Permalink
Add X::Temporal::OutOfRange (#5272)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Leont committed Jun 13, 2023
1 parent a6bec92 commit 83cc6e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core.c/Dateish.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/core.c/Exception.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 83cc6e7

Please sign in to comment.