Add CdpEvent::InvalidParams variant
Fixes #167
Add CdpEvent::InvalidParams(serde_json::Value), and use it if deserializing an event param for a specific method fails.
There already are CdpEvent::Other(serde_json::Value), but it's only used for unknown method ids.
I use the raw_value feature on serde_json to get serde_json::Value without any allocation after deserializing an event param failed.
Hey @ryo33 and @mattsse , any idea when this might be merged? I'm hoping it might fix CdpError::Serde errors like in the following (?):
let handle = tokio::task::spawn(async move {
while let Some(h) = handler.next().await {
if let Err(CdpError::Serde(err)) = h {
println!("Serde error: {:#?}", err);
continue;
} else if let Err(err) = h {
println!("CDP Error: {:#?}", err);
break;
}
}
});
Meanwhile, I guess it's safe to just ignore these errors as those CDP messages are currently unsupported anyway... probably just new Chrome/ium experimental features?
This is not the solution because we try to translate that to a custom event which means the user would need to have a listener with a custom event for each method, this is not viable. The real solution is really to let it fail if the user asks for that or ignore the event entirely. @mattsse this can be closed