-
-
Notifications
You must be signed in to change notification settings - Fork 91
Properly handle exception from missing vscode config json file #2728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
return actions.user.vscode_get_setting(key, default_value), False | ||
except Exception: | ||
print(fallback_message) | ||
traceback.print_exc() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just created a lot of noise in the Talon log. We know were the problem is without this.
try: | ||
vscode_settings_path = actions.user.vscode_settings_path().resolve() | ||
except Exception as ex: | ||
print(ex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the exception that was uncaught and broke Cursorless logic further up the call stack.
try: | ||
vscode_settings_path = actions.user.vscode_settings_path().resolve() | ||
except Exception as ex: | ||
print(ex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try: | |
vscode_settings_path = actions.user.vscode_settings_path().resolve() | |
except Exception as ex: | |
print(ex) | |
try: | |
vscode_settings_path = actions.user.vscode_settings_path().resolve() | |
except Exception as e: | |
print(f"Could not resolve VS Code settings path at {vscode_settings_path} (not fatal): {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to avoid just doing raw printing of exception objects, because then you see the exception message in the log without much context / able to debug them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception message is already well formed
2025-01-16 18:00:29.801 IO Couldn't find VSCode's settings JSON. Tried these paths: C:\Users\andre\AppData\Roaming\Code2\User\settings.json, C:\Users\andre\AppData\Roaming\VSCodium\User\settings.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's defined here
cursorless/cursorless-talon/src/apps/vscode_settings.py
Lines 66 to 73 in 0bad81a
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) |
Today on main this exception is not caught and the Cursorless list containing all the scopes is not filled which means that Cursorless is not working if we can't find the vscode json config file. ## 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 --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Today on main this exception is not caught and the Cursorless list containing all the scopes is not filled which means that Cursorless is not working if we can't find the vscode json config file.
Checklist