From f394c0b443e6ab957b33d6f02dca90f8e5acccc9 Mon Sep 17 00:00:00 2001 From: cristian-paris Date: Sat, 25 Jan 2025 13:56:58 +0200 Subject: [PATCH] Add a clearer panic message if settings.json is malformed --- framework/meta/src/cmd/install/install_debugger.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/framework/meta/src/cmd/install/install_debugger.rs b/framework/meta/src/cmd/install/install_debugger.rs index 0f95aa614b..92edc97ae2 100644 --- a/framework/meta/src/cmd/install/install_debugger.rs +++ b/framework/meta/src/cmd/install/install_debugger.rs @@ -102,7 +102,9 @@ fn configure_vscode() { let script_full_path = get_script_path(home::home_dir().unwrap().join(TARGET_PATH)); let json = fs::read_to_string(&path_to_settings).expect("Unable to read settings.json"); - let mut sub_values: serde_json::Value = serde_json::from_str(&json).unwrap(); + let mut sub_values: serde_json::Value = serde_json::from_str(&json).unwrap_or_else( + |err: serde_json::Error| panic!("Incorrectly formatted VSCode settings.json file. The error is locatted at line {}, column {}. This error might be caused either by a trailling comma in the settings file (which is, actually, pretty usual), or the settings file was not correctly edited and saved. Please check your file via a JSON linter and fix the settings file before attempting to run the install command again.", err.line(), err.column()) + ); let init_commands = sub_values .as_object_mut()