Catch OverflowErrors in the timedelta converter (#4630)

This commit is contained in:
Kowlin 2020-12-16 18:56:42 +01:00 committed by GitHub
parent 06ba425159
commit e519286f5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,7 +112,12 @@ def parse_timedelta(
_("`{unit}` is not a valid unit of time for this command").format(unit=k) _("`{unit}` is not a valid unit of time for this command").format(unit=k)
) )
if params: if params:
try:
delta = timedelta(**params) delta = timedelta(**params)
except OverflowError:
raise BadArgument(
_("The time set is way too high, consider setting something reasonable.")
)
if maximum and maximum < delta: if maximum and maximum < delta:
raise BadArgument( raise BadArgument(
_( _(