File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 6
6
"""
7
7
import typing as t
8
8
9
+ from libtmux ._internal .query_list import ObjectDoesNotExist
10
+
11
+ if t .TYPE_CHECKING :
12
+ from libtmux .neo import ListExtraArgs
13
+
9
14
10
15
class LibTmuxException (Exception ):
11
16
@@ -22,6 +27,25 @@ class TmuxCommandNotFound(LibTmuxException):
22
27
"""Application binary for tmux not found."""
23
28
24
29
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
+
25
49
class VersionTooLow (LibTmuxException ):
26
50
27
51
"""Raised if tmux below the minimum version to use libtmux."""
You can’t perform that action at this time.
0 commit comments