chromiumoxide icon indicating copy to clipboard operation
chromiumoxide copied to clipboard

Add CdpEvent::InvalidParams variant

Open ryo33 opened this issue 1 year ago • 1 comments

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.

ryo33 avatar Feb 15 '24 09:02 ryo33

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?

tgrushka avatar Jul 26 '24 21:07 tgrushka

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

Sytten avatar Oct 24 '24 19:10 Sytten