Skip to content

Commit

Permalink
Show better exception message when vscode settings json is not found (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
AndreasArvidsson committed Aug 17, 2024
1 parent 2306d1b commit 49f7084
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cursorless-talon/src/apps/vscode_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 49f7084

Please sign in to comment.