mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Use OperationalException for TimeRange errors
This commit is contained in:
parent
c304651249
commit
0d5833ed91
|
@ -7,6 +7,8 @@ from typing import Optional
|
||||||
|
|
||||||
import arrow
|
import arrow
|
||||||
|
|
||||||
|
from freqtrade.exceptions import OperationalException
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -104,6 +106,7 @@ class TimeRange:
|
||||||
else:
|
else:
|
||||||
stop = int(stops)
|
stop = int(stops)
|
||||||
if start > stop > 0:
|
if start > stop > 0:
|
||||||
raise Exception('Start date is after stop date for timerange "%s"' % text)
|
raise OperationalException(
|
||||||
|
f'Start date is after stop date for timerange "{text}"')
|
||||||
return TimeRange(stype[0], stype[1], start, stop)
|
return TimeRange(stype[0], stype[1], start, stop)
|
||||||
raise Exception('Incorrect syntax for timerange "%s"' % text)
|
raise OperationalException(f'Incorrect syntax for timerange "{text}"')
|
||||||
|
|
|
@ -3,6 +3,7 @@ import arrow
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
|
from freqtrade.exceptions import OperationalException
|
||||||
|
|
||||||
|
|
||||||
def test_parse_timerange_incorrect():
|
def test_parse_timerange_incorrect():
|
||||||
|
@ -27,10 +28,11 @@ def test_parse_timerange_incorrect():
|
||||||
timerange = TimeRange.parse_timerange('-1231006505000')
|
timerange = TimeRange.parse_timerange('-1231006505000')
|
||||||
assert TimeRange(None, 'date', 0, 1231006505) == timerange
|
assert TimeRange(None, 'date', 0, 1231006505) == timerange
|
||||||
|
|
||||||
with pytest.raises(Exception, match=r'Incorrect syntax.*'):
|
with pytest.raises(OperationalException, match=r'Incorrect syntax.*'):
|
||||||
TimeRange.parse_timerange('-')
|
TimeRange.parse_timerange('-')
|
||||||
|
|
||||||
with pytest.raises(Exception, match=r'Start date is after stop date for timerange.*'):
|
with pytest.raises(OperationalException,
|
||||||
|
match=r'Start date is after stop date for timerange.*'):
|
||||||
TimeRange.parse_timerange('20100523-20100522')
|
TimeRange.parse_timerange('20100523-20100522')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user