From 49f70840f0b11d4fca1744f88af1cd3d91cbd3d5 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 18 Aug 2024 01:07:38 +0200 Subject: [PATCH] Show better exception message when vscode settings json is not found (#2655) Today you get a `ValueError: max() arg is an empty sequence` message that is quite confusing. ## Checklist - [/] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet --- cursorless-talon/src/apps/vscode_settings.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cursorless-talon/src/apps/vscode_settings.py b/cursorless-talon/src/apps/vscode_settings.py index f1ec80a631..20e1e306ec 100644 --- a/cursorless-talon/src/apps/vscode_settings.py +++ b/cursorless-talon/src/apps/vscode_settings.py @@ -67,6 +67,11 @@ def vscode_get_setting_with_fallback( def pick_path(paths: list[Path]) -> Path: existing_paths = [path for path in paths if path.exists()] + if not existing_paths: + paths_str = ", ".join(str(path) for path in paths) + raise FileNotFoundError( + f"Couldn't find VSCode's settings JSON. Tried these paths: {paths_str}" + ) return max(existing_paths, key=lambda path: path.stat().st_mtime)