database: don't overwrite "get" server errors

Make sure the correct exception is raised when "get_item" fails.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-02-19 14:50:22 -05:00
parent 2d28a3eeff
commit 5f96822c90
1 changed files with 3 additions and 1 deletions

View File

@ -333,9 +333,11 @@ class MoonrakerDatabase:
ns = self._get_record(namespace, key_list[0])
val = reduce(operator.getitem, # type: ignore
key_list[1:], ns)
except Exception:
except Exception as e:
if not isinstance(default, SentinelClass):
return default
if isinstance(e, self.server.error):
raise
raise self.server.error(
f"Key '{key}' in namespace '{namespace}' not found", 404)
return val