home · contact · privacy
Add PostvarsParser to isolate postvars parsing/checking.
[plomtask] / plomtask / processes.py
index 4867227e5f4e492ebeeac33c484039f36afca4fd..0300e73ccbaec2f15a5478a892b9fcc9d231eaa3 100644 (file)
@@ -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 '