{"record":{"id":"f6874dae205cce84","repo":"libnyanpasu/clash-nyanpasu","slug":"error-f6874d","errorCode":null,"errorMessage":"{error}","messagePattern":"\\{error\\}","errorType":"exception","errorClass":"ClientError","httpStatus":null,"severity":"error","filePath":"backend/tauri/src/client/mod.rs","lineNumber":204,"sourceCode":"        .context(\"failed to prepare loaded session state legacy mirror\")?\n        .apply();\n\n    let clash_config = clash_config\n        .get()\n        .await\n        .context(\"failed to read loaded clash config\")?\n        .state;\n    bridges\n        .clash\n        .prepare(&clash_config)\n        .context(\"failed to prepare loaded clash config legacy mirror\")?\n        .apply();\n\n    Ok(())\n}\n\nfn client_error_from_core(error: nyanpasu_core_manager::CoreError) -> ClientError {\n    ClientError::Anyhow(anyhow::anyhow!(error))\n}\n\n#[cfg(not(test))]\nfn runtime_core_spec(\n    core: &nyanpasu_config::application::ClashCore,\n) -> anyhow::Result<nyanpasu_core_manager::CoreSpec> {\n    crate::core::actor_v2::local_host::core_spec(core)\n}\n\n#[cfg(test)]\nfn runtime_core_spec(\n    core: &nyanpasu_config::application::ClashCore,\n) -> anyhow::Result<nyanpasu_core_manager::CoreSpec> {\n    use nyanpasu_core_manager::CoreKind;\n    let kind = match core {\n        nyanpasu_config::application::ClashCore::ClashPremium => CoreKind::ClashPremium,\n        nyanpasu_config::application::ClashCore::ClashRs\n        | nyanpasu_config::application::ClashCore::ClashRsAlpha => CoreKind::ClashRust,","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/client/mod.rs#L186-L222","documentation":"client_error_from_core converts a nyanpasu_core_manager::CoreError into the client-layer ClientError by wrapping it in anyhow! (ClientError::Anyhow). The displayed message \"{error}\" is simply the Display of the underlying CoreError — this site is an error-mapping shim, not the origin; the actual cause (core spawn failure, spec conversion, etc.) comes from the core manager.","triggerScenarios":"Any client operation whose core-manager call returns Err(CoreError) — e.g. starting/restarting the core, building a core spec from a ClashCore variant, or core process lifecycle operations — while being converted to a ClientError for the facade/command layer.","commonSituations":"Sidecar core binary missing or incompatible with the platform; invalid runtime config passed to the core; core process crashes immediately on startup; unsupported ClashCore variant mapped to a bad CoreSpec.","solutions":["Read the wrapped CoreError message (the {error} payload) to find the real failure, then address that root cause (missing binary, bad spec, crash).","Verify the selected core binary exists at the expected sidecar path and matches the OS/arch (re-run pnpm prepare:check or re-download the sidecar).","Validate the runtime config before starting the core; fix any schema or field errors reported by the core.","If a specific ClashCore variant consistently fails, check runtime_core_spec mapping for that variant and use a supported core."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn as_core_error(client_err: &ClientError) -> Option<&nyanpasu_core_manager::CoreError> {\n    match client_err {\n        ClientError::Anyhow(e) => e.downcast_ref::<nyanpasu_core_manager::CoreError>(),\n        _ => None,\n    }\n}","tryCatchPattern":"match client.restart_core().await {\n    Err(err) => match as_core_error(&err) {\n        Some(core_err) => report_core_failure(core_err), // inspect Display of wrapped CoreError\n        None => return Err(err.into()),\n    },\n    Ok(()) => {},\n}","preventionTips":["Always log the full error chain (anyhow {:?}) so the wrapped CoreError details are visible","Verify sidecar binaries exist for the current platform before starting cores","Validate runtime config before core launch to avoid the most common CoreError causes","Keep ClientError variants typed where possible instead of funneling through ClientError::Anyhow"],"tags":["error-mapping","core-manager","process"],"backgroundTag":"api-error-response","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}