Repository: servo/servo
File: components/script/dom/console.rs (Rust)

Code before:
#[derive(Debug, Eq, PartialEq)]
enum IncludeStackTrace {
    Yes,
    No,
}

impl consoleMethods<crate::DomTypeHolder> for Console {
    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/log>
    fn Log(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {
        Console::method(
            global,
            ConsoleLogLevel::Log,
            messages,
            IncludeStackTrace::No,
        );
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/clear>
    fn Clear(global: &GlobalScope) {
        if let Some(chan) = global.devtools_chan() {
            let worker_id = global
                .downcast::<WorkerGlobalScope>()
                .map(|worker| worker.worker_id());
            let devtools_message =
                ScriptToDevtoolsControlMsg::ClearConsole(global.pipeline_id(), worker_id);
            chan.send(devtools_message).unwrap();
        }
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console>
    fn Debug(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {
        Console::method(
            global,
            ConsoleLogLevel::Debug,
            messages,
            IncludeStackTrace::No,
        );
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/info>
    fn Info(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {
        Console::method(
            global,
            ConsoleLogLevel::Info,
            messages,
            IncludeStackTrace::No,
        );
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/warn>
    fn Warn(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {

Review comment (suggestion):
```suggestion
            if let Err(error) = chan.send(devtools_message) {
                log::warn!("Error sending clear message to devtools: {error:?}");
            }
```

Code after:
#[derive(Debug, Eq, PartialEq)]
enum IncludeStackTrace {
    Yes,
    No,
}

impl consoleMethods<crate::DomTypeHolder> for Console {
    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/log>
    fn Log(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {
        Console::method(
            global,
            ConsoleLogLevel::Log,
            messages,
            IncludeStackTrace::No,
        );
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/clear>
    fn Clear(global: &GlobalScope) {
        if let Some(chan) = global.devtools_chan() {
            let worker_id = global
                .downcast::<WorkerGlobalScope>()
                .map(|worker| worker.worker_id());
            let devtools_message =
                ScriptToDevtoolsControlMsg::ClearConsole(global.pipeline_id(), worker_id);
            if let Err(error) = chan.send(devtools_message) {
                log::warn!("Error sending clear message to devtools: {error:?}");
            }
        }
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console>
    fn Debug(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {
        Console::method(
            global,
            ConsoleLogLevel::Debug,
            messages,
            IncludeStackTrace::No,
        );
    }

    /// <https://developer.mozilla.org/en-US/docs/Web/API/Console/info>
    fn Info(_cx: JSContext, global: &GlobalScope, messages: Vec<HandleValue>) {
        Console::method(
            global,
            ConsoleLogLevel::Info,
            messages,
            IncludeStackTrace::No,
        );
    }