KeiSeiKit-1.0/_primitives/_rust/kei-compute-baremetal/src/error.rs
Parfii-bot 0be354a920 KeiSeiKit-public — clean state
Single-commit clean baseline after security scrub of niche-tells,
project codenames, internal jargon, and contributor-email leaks.

Contents:
- 100 Rust crates (_primitives/_rust/)
- 37 agent manifests (_manifests/) + generated specs (_generated/)
- 67 user-invocable skills (skills/)
- 33 hooks (hooks/)
- Composition blocks (_blocks/)
- Documentation (docs/, README.md)
- TS adapter packages (_ts_packages/)
- Assembler (_assembler/)
- Roles (_roles/)
- Templates (_templates/)
- Forgejo CI (.forgejo/)

Author: Denis Parfionovich <info@greendragon.info>

License: see LICENSE.
2026-05-01 12:09:03 +08:00

49 lines
1.7 KiB
Rust

// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 Denis Parfionovich
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("io: {0}")]
Io(#[from] std::io::Error),
#[error("DNA: {0}")]
Dna(#[from] kei_shared::dna::DnaError),
#[error("operation '{op}' not implemented for bare-metal provider (manual user action required)")]
NotImplemented { op: &'static str },
#[error("SSH connection to '{host}' failed: {detail}")]
ConnectionFailed { host: String, detail: String },
#[error("VM not found: {0}")]
NotFound(String),
#[error("invalid external_id (expected ssh://user@host[:port]): {0}")]
InvalidExternalId(String),
}
pub type Result<T> = std::result::Result<T, Error>;
/// Map our errors into the runtime-core error type expected by the
/// `ComputeProvider` trait. `NotImplemented` is surfaced as `Provider`
/// since runtime-core has no dedicated variant for it.
impl From<Error> for kei_runtime_core::Error {
fn from(e: Error) -> Self {
match e {
Error::NotFound(s) => kei_runtime_core::Error::NotFound(s),
Error::Dna(e) => kei_runtime_core::Error::Dna(e),
Error::NotImplemented { op } => kei_runtime_core::Error::Provider(format!(
"baremetal: '{op}' not implemented (manual action required)"
)),
Error::ConnectionFailed { host, detail } => {
kei_runtime_core::Error::Provider(format!("baremetal SSH '{host}': {detail}"))
}
Error::InvalidExternalId(s) => {
kei_runtime_core::Error::Provider(format!("baremetal invalid id: {s}"))
}
Error::Io(e) => kei_runtime_core::Error::Provider(format!("baremetal io: {e}")),
}
}
}