zed-industries/zed · error

{context}

Error message

{context}

What it means

A generic wrapper (WprContext::wpr_context) that converts a windows_core error from a WPR (Windows Performance Recorder) COM call into an anyhow error whose message is the enriched error context: HRESULT code plus IErrorInfo description. It fires whenever the wrapped COM/API call returns Err; the message itself carries the OS-specific failure detail, so the root cause is the underlying Windows API error code.

Solutions

  1. Inspect the HRESULT inside the context string to identify the failing WPR API (permission, session state, provider missing)
  2. Run elevated / as admin for WPR recording sessions that require it
  3. Propagate the error to the caller with additional context naming the WPR operation attempted
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/etw_tracing/etw_tracing.rs:391 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/4e3c72a6d12278ae. Report an issue: GitHub.

Appendix: source

Thrown at crates/etw_tracing/etw_tracing.rs:391

            {
                let _ = write!(out, "\n  IErrorInfo: {desc}");
            }
        }
    }

    out
}

trait WprContext<T> {
    fn wpr_context(self, source: &impl Interface) -> Result<T>;
}

impl<T> WprContext<T> for windows_core::Result<T> {
    fn wpr_context(self, source: &impl Interface) -> Result<T> {
        self.map_err(|e| {
            let unknown: windows_core::IUnknown = source.cast().expect("cast to IUnknown");
            let context = wpr_error_context(e.code(), &unknown);
            anyhow::anyhow!("{context}")
        })
    }
}

fn create_wpr<T: windows_core::Interface>(clsid: &windows_core::GUID) -> Result<T> {
    unsafe {
        WPRCCreateInstanceUnderInstanceName::<_, T>(
            &BSTR::from(INSTANCE_NAME),
            clsid,
            None,
            CLSCTX_INPROC_SERVER.0,
        )
        .context("WPRCCreateInstance failed")
    }
}

fn build_profile_collection(heap_pid: Option<u32>) -> Result<IProfileCollection> {
    let collection: IProfileCollection = create_wpr(&CProfileCollection)?;

View on GitHub (pinned to f4178619ac)