Skip to content

Commit cecf056

Browse files
committed
fix(cli/load): Narrow exception handling in load_plugins()
Replace bare `except Exception` with specific exception types: - First try block: `except AttributeError` for string operations on non-string plugin values - Second try block: `except (ImportError, AttributeError)` for module import failures and missing plugin class attributes This prevents catching unrelated errors like KeyboardInterrupt or MemoryError that should propagate up.
1 parent d43aced commit cecf056

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/tmuxp/cli/load.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def load_plugins(
119119
module_name = plugin.split(".")
120120
module_name = ".".join(module_name[:-1])
121121
plugin_name = plugin.split(".")[-1]
122-
except Exception as error:
122+
except AttributeError as error:
123123
tmuxp_echo(
124124
colors.error("[Plugin Error]")
125125
+ f" Couldn't load {plugin}\n"
@@ -141,7 +141,7 @@ def load_plugins(
141141
+ " Plugin versions constraint not met. Exiting...",
142142
)
143143
sys.exit(1)
144-
except Exception as error:
144+
except (ImportError, AttributeError) as error:
145145
tmuxp_echo(
146146
colors.error("[Plugin Error]")
147147
+ f" Couldn't load {plugin}\n"

0 commit comments

Comments
 (0)