chrome_devtools/domain/runtime/event/
mod.rs1use crate::domain::runtime::r#type::RemoteObject;
4use serde::{Deserialize, Serialize};
5use std::fmt;
6pub mod console_api_called;
7
8#[derive(Debug, Serialize, Deserialize, Clone)]
9#[non_exhaustive]
10#[serde(tag = "method", content = "params")]
11pub enum Event {
12 #[serde(rename = "Runtime.consoleAPICalled")]
13 ConsoleAPICalled(console_api_called::Event),
14 #[serde(rename = "Runtime.exceptionThrown")]
15 ExceptionThrown(ExceptionParams),
16}
17
18#[derive(Debug, Serialize, Deserialize, Clone)]
19#[non_exhaustive]
20#[serde(rename_all = "camelCase")]
21pub struct ExceptionParams {
22 pub timestamp: i64,
23 pub exception_details: ExceptionDetails,
24}
25
26#[derive(Debug, Serialize, Deserialize, Clone)]
27#[serde(rename_all = "camelCase")]
28pub struct ExceptionDetails {
29 pub text: String,
30 pub line_number: i32,
31 pub column_number: i32,
32 pub url: Option<String>,
33 pub exception: RemoteObject,
34}
35
36impl fmt::Display for Event {
37 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
38 match &self {
39 Event::ConsoleAPICalled(event) => write!(f, "{}", event),
40 Event::ExceptionThrown(params) => params.exception_details.text.fmt(f),
41 }
42 }
43}