diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-12-18 11:43:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 11:43:02 +0100 |
commit | a44a5de43013becb91e4725e508051e62f628467 (patch) | |
tree | f12a4135816cea35f4853ff2730a0df2275091e5 /cli/cdp.rs | |
parent | 9ede8d7b69c1d2859bb03e5bdffd7407042914ec (diff) |
refactor: factor out cdp::ExceptionThrown notification (#21623)
Just removing some duplicated code.
Diffstat (limited to 'cli/cdp.rs')
-rw-r--r-- | cli/cdp.rs | 24 |
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, +} |