summaryrefslogtreecommitdiff
path: root/cli/cdp.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-12-18 11:43:02 +0100
committerGitHub <noreply@github.com>2023-12-18 11:43:02 +0100
commita44a5de43013becb91e4725e508051e62f628467 (patch)
treef12a4135816cea35f4853ff2730a0df2275091e5 /cli/cdp.rs
parent9ede8d7b69c1d2859bb03e5bdffd7407042914ec (diff)
refactor: factor out cdp::ExceptionThrown notification (#21623)
Just removing some duplicated code.
Diffstat (limited to 'cli/cdp.rs')
-rw-r--r--cli/cdp.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/cli/cdp.rs b/cli/cdp.rs
index cb9933a03..6c2adc552 100644
--- a/cli/cdp.rs
+++ b/cli/cdp.rs
@@ -322,6 +322,17 @@ pub struct ExceptionDetails {
pub exception_meta_data: Option<serde_json::Map<String, Value>>,
}
+impl ExceptionDetails {
+ pub fn get_message_and_description(&self) -> (String, String) {
+ let description = self
+ .exception
+ .clone()
+ .and_then(|ex| ex.description)
+ .unwrap_or_else(|| "undefined".to_string());
+ (self.text.to_string(), description)
+ }
+}
+
/// <https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#type-StackTrace>
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
@@ -502,3 +513,16 @@ pub struct TakePreciseCoverageResponse {
pub result: Vec<ScriptCoverage>,
pub timestamp: f64,
}
+
+#[derive(Debug, Deserialize)]
+pub struct Notification {
+ pub method: String,
+ pub params: Value,
+}
+/// <https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#event-exceptionThrown>
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct ExceptionThrown {
+ pub timestamp: f64,
+ pub exception_details: ExceptionDetails,
+}