Skip to content

Commit 881699a

Browse files
committed
Catch ResourceNotFoundException
1 parent d224bfa commit 881699a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pydanticrud/backends/dynamodb.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,12 @@ def query(self, query_expr: Optional[Rule] = None, filter_expr: Optional[Rule] =
318318

319319
def get(self, key):
320320
_key = self._key_param_to_dict(key)
321-
resp = self.get_table().get_item(Key=_key)
321+
try:
322+
resp = self.get_table().get_item(Key=_key)
323+
except ClientError as e:
324+
if e.response["Error"]["Code"] == "ResourceNotFoundException":
325+
raise DoesNotExist(f'{self.table_name} "{_key}" does not exist')
326+
raise e
322327

323328
if "Item" not in resp:
324329
if not self.range_key:

0 commit comments

Comments
 (0)