libnyanpasu/clash-nyanpasu · error · ClientError
{error}
Error message
{error} What it means
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.
Source
Thrown at backend/tauri/src/client/mod.rs:204
.context("failed to prepare loaded session state legacy mirror")?
.apply();
let clash_config = clash_config
.get()
.await
.context("failed to read loaded clash config")?
.state;
bridges
.clash
.prepare(&clash_config)
.context("failed to prepare loaded clash config legacy mirror")?
.apply();
Ok(())
}
fn client_error_from_core(error: nyanpasu_core_manager::CoreError) -> ClientError {
ClientError::Anyhow(anyhow::anyhow!(error))
}
#[cfg(not(test))]
fn runtime_core_spec(
core: &nyanpasu_config::application::ClashCore,
) -> anyhow::Result<nyanpasu_core_manager::CoreSpec> {
crate::core::actor_v2::local_host::core_spec(core)
}
#[cfg(test)]
fn runtime_core_spec(
core: &nyanpasu_config::application::ClashCore,
) -> anyhow::Result<nyanpasu_core_manager::CoreSpec> {
use nyanpasu_core_manager::CoreKind;
let kind = match core {
nyanpasu_config::application::ClashCore::ClashPremium => CoreKind::ClashPremium,
nyanpasu_config::application::ClashCore::ClashRs
| nyanpasu_config::application::ClashCore::ClashRsAlpha => CoreKind::ClashRust,View on GitHub (pinned to f7dbce2997)
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.
Defensive patterns
Strategy: try-catch
Type guard
fn as_core_error(client_err: &ClientError) -> Option<&nyanpasu_core_manager::CoreError> {
match client_err {
ClientError::Anyhow(e) => e.downcast_ref::<nyanpasu_core_manager::CoreError>(),
_ => None,
}
} Try / catch
match client.restart_core().await {
Err(err) => match as_core_error(&err) {
Some(core_err) => report_core_failure(core_err), // inspect Display of wrapped CoreError
None => return Err(err.into()),
},
Ok(()) => {},
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {operation} failed with status {status}
- {stderr}
- failed to copy core: {status}
- Failed to wait for child: {:?}, errs: {}
- child process failed: {:?}, err: {}
AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08).
Data as JSON: /api/errors/f6874dae205cce84.
Report an issue: GitHub.