from __future__ import annotations
from datetime import datetime, timedelta
from sqlite3 import Row
-from plomtask.misc import HandledException
+from plomtask.exceptions import BadFormatException, NotFoundException
from plomtask.db import DatabaseConnection
DATE_FORMAT = '%Y-%m-%d'
dt = datetime.strptime(date_str, DATE_FORMAT)
except (ValueError, TypeError) as e:
msg = f'Given date of wrong format: {date_str}'
- raise HandledException(msg) from e
+ raise BadFormatException(msg) from e
return dt.strftime(DATE_FORMAT)
for row in db_conn.exec('SELECT * FROM days WHERE date = ?', (date,)):
return cls.from_table_row(row)
if not create:
- raise HandledException(f'Day not found for date: {date}')
+ raise NotFoundException(f'Day not found for date: {date}')
return cls(date)
@property