{"record":{"id":"4e3c72a6d12278ae","repo":"zed-industries/zed","slug":"context","errorCode":null,"errorMessage":"{context}","messagePattern":"\\{context\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/etw_tracing/etw_tracing.rs","lineNumber":391,"sourceCode":"            {\n                let _ = write!(out, \"\\n  IErrorInfo: {desc}\");\n            }\n        }\n    }\n\n    out\n}\n\ntrait WprContext<T> {\n    fn wpr_context(self, source: &impl Interface) -> Result<T>;\n}\n\nimpl<T> WprContext<T> for windows_core::Result<T> {\n    fn wpr_context(self, source: &impl Interface) -> Result<T> {\n        self.map_err(|e| {\n            let unknown: windows_core::IUnknown = source.cast().expect(\"cast to IUnknown\");\n            let context = wpr_error_context(e.code(), &unknown);\n            anyhow::anyhow!(\"{context}\")\n        })\n    }\n}\n\nfn create_wpr<T: windows_core::Interface>(clsid: &windows_core::GUID) -> Result<T> {\n    unsafe {\n        WPRCCreateInstanceUnderInstanceName::<_, T>(\n            &BSTR::from(INSTANCE_NAME),\n            clsid,\n            None,\n            CLSCTX_INPROC_SERVER.0,\n        )\n        .context(\"WPRCCreateInstance failed\")\n    }\n}\n\nfn build_profile_collection(heap_pid: Option<u32>) -> Result<IProfileCollection> {\n    let collection: IProfileCollection = create_wpr(&CProfileCollection)?;","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/etw_tracing/etw_tracing.rs#L373-L409","documentation":"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.","triggerScenarios":"Thrown at crates/etw_tracing/etw_tracing.rs:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the HRESULT inside the context string to identify the failing WPR API (permission, session state, provider missing)","Run elevated / as admin for WPR recording sessions that require it","Propagate the error to the caller with additional context naming the WPR operation attempted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}