Skip to content

Commit 69fa725

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

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/tmuxp/cli/search.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
from __future__ import annotations
2525

2626
import argparse
27+
import json
2728
import pathlib
2829
import re
2930
import typing as t
3031

32+
import yaml
33+
3134
from tmuxp._internal.config_reader import ConfigReader
3235
from tmuxp._internal.private_path import PrivatePath
3336
from tmuxp.workspace.constants import VALID_WORKSPACE_DIR_FILE_EXTENSIONS
@@ -602,7 +605,7 @@ def extract_workspace_fields(filepath: pathlib.Path) -> WorkspaceFields:
602605
panes.append(cmds)
603606
elif isinstance(cmds, list):
604607
panes.extend(str(cmd) for cmd in cmds if cmd)
605-
except Exception:
608+
except (yaml.YAMLError, json.JSONDecodeError, OSError):
606609
# If config parsing fails, continue with empty content fields
607610
pass
608611

0 commit comments

Comments
 (0)