Skip to content

Commit fd54fa1

Browse files
committed
refactor(query_list): Extract exceptions
1 parent 3f51d4a commit fd54fa1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/libtmux/_internal/query_list.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ def keygetter(
5959
elif hasattr(dct, sub_field):
6060
dct = getattr(dct, sub_field)
6161

62-
return dct
6362
except Exception as e:
6463
traceback.print_stack()
6564
print(f"Above error was {e}")
66-
return None
65+
return None
66+
67+
return dct
6768

6869

6970
def parse_lookup(obj: "Mapping[str, Any]", path: str, lookup: str) -> Optional[Any]:
@@ -294,7 +295,7 @@ class QueryList(List[T]):
294295

295296
def items(self) -> List[T]:
296297
if self.pk_key is None:
297-
raise Exception("items() require a pk_key exists")
298+
raise PKRequiredException()
298299
return [(getattr(item, self.pk_key), item) for item in self]
299300

300301
def __eq__(
@@ -334,7 +335,7 @@ def filter_lookup(obj: Any) -> bool:
334335
lhs, op = path.rsplit("__", 1)
335336

336337
if op not in LOOKUP_NAME_MAP:
337-
raise ValueError(f"{op} not in LOOKUP_NAME_MAP")
338+
raise OpNotFound(op=op)
338339
except ValueError:
339340
lhs = path
340341
op = "exact"

0 commit comments

Comments
 (0)