Skip to content

Commit 1b97bfd

Browse files
committed
fix(cli/ls): Use specific exceptions for config parse errors
Replace bare `except Exception` with `except (yaml.YAMLError, json.JSONDecodeError, OSError)` in `_get_workspace_info()`. This ensures only expected errors from config file parsing are caught, allowing unrelated errors to propagate for proper debugging.
1 parent cecf056 commit 1b97bfd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/tmuxp/cli/ls.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@
2828

2929
import argparse
3030
import datetime
31+
import json
3132
import pathlib
3233
import typing as t
3334

35+
import yaml
36+
3437
from tmuxp._internal.config_reader import ConfigReader
3538
from tmuxp._internal.private_path import PrivatePath
3639
from tmuxp.workspace.constants import VALID_WORKSPACE_DIR_FILE_EXTENSIONS
@@ -226,7 +229,7 @@ def _get_workspace_info(
226229
session_name = config.content.get("session_name")
227230
if include_config:
228231
config_content = config.content
229-
except Exception:
232+
except (yaml.YAMLError, json.JSONDecodeError, OSError):
230233
# If we can't parse it, just skip session_name
231234
pass
232235

0 commit comments

Comments
 (0)