Skip to content

Commit

Permalink
Raise ItemDoesNotExistError if Item is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Jun 16, 2021
1 parent 7e966e9 commit afecc47
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/webqueue2api/parser/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from typing import Union
from pathlib import Path
from .config import config
from .errors import ItemDoesNotExistError



Expand Down Expand Up @@ -36,6 +37,9 @@ class Item:
department: The most recent department for this item.
dateReceived: The date this item was created.
jsonData: A JSON serializable representation of the Item.
Raises:
ItemDoesNotExistError: If an item does not exist on the filesystem.
"""

def __init__(self, queue: str, number: int) -> None:
Expand All @@ -47,6 +51,9 @@ def __init__(self, queue: str, number: int) -> None:
raise ValueError(f"Could not convert {number} to an integer")

self.__path = Path(config.queue_directory, self.queue, str(self.number))
if not self.__path.exists():
raise ItemDoesNotExistError(str(self.__path))

self.lastUpdated = self.__getLastUpdated()
self.__rawItem = self.__getRawItem()
self.headers = self.__parseHeaders()
Expand Down

0 comments on commit afecc47

Please sign in to comment.