diff options
-rw-r--r-- | cli/import_map.rs | 17 | ||||
-rw-r--r-- | runtime/ops/tty.rs | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/cli/import_map.rs b/cli/import_map.rs index 17ac3727e..aa76d8d76 100644 --- a/cli/import_map.rs +++ b/cli/import_map.rs @@ -65,10 +65,11 @@ impl ImportMap { ) -> Result<Self, ImportMapError> { let v: Value = match serde_json::from_str(json_string) { Ok(v) => v, - Err(_) => { - return Err(ImportMapError::Other( - "Unable to parse import map JSON".to_string(), - )); + Err(err) => { + return Err(ImportMapError::Other(format!( + "Unable to parse import map JSON: {}", + err.to_string() + ))); } }; @@ -742,6 +743,14 @@ mod tests { assert!(ImportMap::from_json(base_url, non_object).is_err()); } + // invalid JSON message test + assert_eq!( + ImportMap::from_json(base_url, "{\"a\":1,}") + .unwrap_err() + .to_string(), + "Unable to parse import map JSON: trailing comma at line 1 column 8", + ); + // invalid schema: 'imports' is non-object for non_object in non_object_strings.to_vec() { assert!(ImportMap::from_json( diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs index bc45c9375..e9e2e6700 100644 --- a/runtime/ops/tty.rs +++ b/runtime/ops/tty.rs @@ -228,7 +228,7 @@ fn op_isatty( { use winapi::um::consoleapi; - let handle = get_windows_handle(&std_file)?; + let handle = get_windows_handle(std_file)?; let mut test_mode: DWORD = 0; // If I cannot get mode out of console, it is not a console. Ok(unsafe { consoleapi::GetConsoleMode(handle, &mut test_mode) != 0 }) |