diff options
author | Casper Beyer <caspervonb@pm.me> | 2020-12-15 00:37:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-14 11:37:08 -0500 |
commit | ce6b738ac08b66b0ee8bfa3f17f8510ab094d5d9 (patch) | |
tree | 17451cbc28396e7da39e3b72259f9f3ac89c7b96 /runtime/inspector.rs | |
parent | 8f8749095c0dc5e71104228de650f671674f6fdc (diff) |
fix(repl): recover from invalid input (#8759)
Diffstat (limited to 'runtime/inspector.rs')
-rw-r--r-- | runtime/inspector.rs | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/runtime/inspector.rs b/runtime/inspector.rs index 89fd5bf57..fc0e793d9 100644 --- a/runtime/inspector.rs +++ b/runtime/inspector.rs @@ -859,7 +859,28 @@ impl v8::inspector::ChannelImpl for InspectorSession { message: v8::UniquePtr<v8::inspector::StringBuffer>, ) { let raw_message = message.unwrap().string().to_string(); - let message = serde_json::from_str(&raw_message).unwrap(); + let message: serde_json::Value = match serde_json::from_str(&raw_message) { + Ok(v) => v, + Err(error) => match error.classify() { + serde_json::error::Category::Syntax => json!({ + "id": call_id, + "result": { + "result": { + "type": "error", + "description": "Unterminated string literal", + "value": "Unterminated string literal", + }, + "exceptionDetails": { + "exceptionId": 0, + "text": "Unterminated string literal", + "lineNumber": 0, + "columnNumber": 0 + }, + }, + }), + _ => panic!("Could not parse inspector message"), + }, + }; self .response_tx_map |