Properly handle exception from missing vscode config json file#2728
Properly handle exception from missing vscode config json file#2728AndreasArvidsson merged 4 commits intomainfrom
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.
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.
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.
| 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.
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.
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.
It's defined here
cursorless/cursorless-talon/src/apps/vscode_settings.py
Lines 66 to 73 in 0bad81a
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