X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=plomtask%2Fprocesses.py;h=0300e73ccbaec2f15a5478a892b9fcc9d231eaa3;hb=8aa3103f8e131b8925ac9daafadf2db77886c910;hp=4867227e5f4e492ebeeac33c484039f36afca4fd;hpb=3558a14701955de18ae7adbda0e93aaee7710a92;p=plomtask diff --git a/plomtask/processes.py b/plomtask/processes.py index 4867227..0300e73 100644 --- a/plomtask/processes.py +++ b/plomtask/processes.py @@ -3,14 +3,16 @@ from __future__ import annotations from sqlite3 import Row from datetime import datetime from plomtask.db import DatabaseConnection -from plomtask.misc import HandledException +from plomtask.exceptions import NotFoundException, BadFormatException class Process: """Template for, and metadata for, Todos, and their arrangements.""" def __init__(self, id_: int | None) -> None: - self.id_ = id_ if id_ != 0 else None # to avoid DB-confusing rowid=0 + if (id_ is not None) and id_ < 1: + raise BadFormatException(f'illegal Process ID, must be >=1: {id_}') + self.id_ = id_ self.title = VersionedAttribute(self, 'title', 'UNNAMED') self.description = VersionedAttribute(self, 'description', '') self.effort = VersionedAttribute(self, 'effort', 1.0) @@ -46,7 +48,7 @@ class Process: break if not process: if not create: - raise HandledException(f'Process not found of id: {id_}') + raise NotFoundException(f'Process not found of id: {id_}') process = Process(id_) if process: for row in db_conn.exec('SELECT * FROM process_titles '