We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8d9d593 commit d83685cCopy full SHA for d83685c
src/libtmux/_internal/query_list.py
@@ -30,6 +30,14 @@ def __call__(
30
no_arg = object()
31
32
33
+class MultipleObjectsReturned(Exception):
34
+ """The requested object does not exist"""
35
+
36
37
+class ObjectDoesNotExist(Exception):
38
+ """The query returned multiple objects when only one was expected."""
39
40
41
def keygetter(
42
obj: "Mapping[str, Any]",
43
path: str,
@@ -368,9 +376,9 @@ def get(
368
376
"""
369
377
objs = self.filter(matcher=matcher, **kwargs)
370
378
if len(objs) > 1:
371
- raise Exception("Multiple objects returned")
379
+ raise MultipleObjectsReturned()
372
380
elif len(objs) == 0:
373
381
if default == no_arg:
374
- raise Exception("No objects found")
382
+ raise ObjectDoesNotExist()
375
383
return default
384
return objs[0]
0 commit comments