home
·
contact
·
privacy
projects
/
plomtask
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use different exceptions throwing different HTTP codes for different cases.
[plomtask]
/
plomtask
/
processes.py
diff --git
a/plomtask/processes.py
b/plomtask/processes.py
index 8a5bf64d640ba4cd5d3d0aad7ea5306102d92670..8b5ff4221ea292b1c8bcffb787671b44129f0a66 100644
(file)
--- a/
plomtask/processes.py
+++ b/
plomtask/processes.py
@@
-3,6
+3,7
@@
from __future__ import annotations
from sqlite3 import Row
from datetime import datetime
from plomtask.db import DatabaseConnection
from sqlite3 import Row
from datetime import datetime
from plomtask.db import DatabaseConnection
+from plomtask.exceptions import NotFoundException
class Process:
class Process:
@@
-35,15
+36,17
@@
class Process:
return list(processes.values())
@classmethod
return list(processes.values())
@classmethod
- def by_id(cls, db_conn: DatabaseConnection,
-
id_: int | None, create: bool = False) -> Process | None
:
+ def by_id(cls, db_conn: DatabaseConnection,
id_: int | None,
+
create: bool = False) -> Process
:
"""Collect all Processes and their connected VersionedAttributes."""
process = None
for row in db_conn.exec('SELECT * FROM processes '
'WHERE id = ?', (id_,)):
process = cls(row[0])
break
"""Collect all Processes and their connected VersionedAttributes."""
process = None
for row in db_conn.exec('SELECT * FROM processes '
'WHERE id = ?', (id_,)):
process = cls(row[0])
break
- if create and not process:
+ if not process:
+ if not create:
+ raise NotFoundException(f'Process not found of id: {id_}')
process = Process(id_)
if process:
for row in db_conn.exec('SELECT * FROM process_titles '
process = Process(id_)
if process:
for row in db_conn.exec('SELECT * FROM process_titles '