2022-02-26 15:11:21 +00:00
|
|
|
import datetime
|
|
|
|
from typing import Literal
|
|
|
|
|
|
|
|
|
2022-02-26 07:16:42 +00:00
|
|
|
class DateNotFoundError(Exception):
|
|
|
|
"""Exception to be raised when date is not found"""
|
|
|
|
|
|
|
|
def __init__(self, message, date):
|
|
|
|
message = f"{message}: {date}"
|
|
|
|
super().__init__(message)
|
2022-02-26 15:11:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
class DateOutOfRangeError(Exception):
|
|
|
|
"""Exception to be raised when provided date is outside the range of dates in the time series"""
|
|
|
|
|
2022-06-25 07:50:44 +00:00
|
|
|
def __init__(self, date: datetime.datetime, type: Literal["min", "max"]) -> None:
|
|
|
|
if type == "min":
|
2022-02-26 15:11:21 +00:00
|
|
|
message = f"Provided date {date} is before the first date in the TimeSeries"
|
2022-06-25 07:50:44 +00:00
|
|
|
if type == "max":
|
2022-02-26 15:11:21 +00:00
|
|
|
message = f"Provided date {date} is after the last date in the TimeSeries"
|
|
|
|
super().__init__(message)
|