File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 66"""
77import typing as t
88
9+ from libtmux ._internal .query_list import ObjectDoesNotExist
10+
11+ if t .TYPE_CHECKING :
12+ from libtmux .neo import ListExtraArgs
13+
914
1015class LibTmuxException (Exception ):
1116
@@ -22,6 +27,25 @@ class TmuxCommandNotFound(LibTmuxException):
2227 """Application binary for tmux not found."""
2328
2429
30+ class TmuxObjectDoesNotExist (ObjectDoesNotExist ):
31+ """The query returned multiple objects when only one was expected."""
32+
33+ def __init__ (
34+ self ,
35+ obj_key : t .Optional [str ] = None ,
36+ obj_id : t .Optional [str ] = None ,
37+ list_cmd : t .Optional [str ] = None ,
38+ list_extra_args : "t.Optional[ListExtraArgs]" = None ,
39+ * args : object ,
40+ ):
41+ if all (arg is not None for arg in [obj_key , obj_id , list_cmd , list_extra_args ]):
42+ return super ().__init__ (
43+ f"Could not find { obj_key } ={ obj_id } for { list_cmd } "
44+ f'{ list_extra_args if list_extra_args is not None else "" } '
45+ )
46+ return super ().__init__ ("Could not find object" )
47+
48+
2549class VersionTooLow (LibTmuxException ):
2650
2751 """Raised if tmux below the minimum version to use libtmux."""
You can’t perform that action at this time.
0 commit comments