KeiSeiKit-1.0/_primitives/_rust/kei-compute-linode/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

60 lines
1.8 KiB
Rust

// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 <author org>
use thiserror::Error;
/// Local crate errors. Mapped into `kei_runtime_core::Error` at the
/// `ComputeProvider` boundary so callers see one error vocabulary.
#[derive(Debug, Error)]
pub enum Error {
#[error("config: {0}")]
Config(String),
#[error("auth: {0}")]
Auth(String),
#[error("http: {0}")]
Http(#[from] reqwest::Error),
#[error("api: {status} — {body}")]
Api { status: u16, body: String },
#[error("not found: {0}")]
NotFound(String),
#[error("invalid tier: {0}")]
InvalidTier(String),
#[error("serde: {0}")]
Serde(#[from] serde_json::Error),
#[error("dna: {0}")]
Dna(#[from] kei_shared::dna::DnaError),
#[error("other: {0}")]
Other(String),
}
pub type Result<T> = std::result::Result<T, Error>;
/// Map crate errors into the runtime-core error vocabulary so trait
/// impls satisfy `kei_runtime_core::Result<T>`.
impl From<Error> for kei_runtime_core::Error {
fn from(e: Error) -> Self {
match e {
Error::Config(s) => kei_runtime_core::Error::Config(s),
Error::Auth(s) => kei_runtime_core::Error::Auth(s),
Error::Http(e) => kei_runtime_core::Error::Network(e.to_string()),
Error::Api { status, body } => {
kei_runtime_core::Error::Provider(format!("linode {status}: {body}"))
}
Error::NotFound(s) => kei_runtime_core::Error::NotFound(s),
Error::InvalidTier(s) => {
kei_runtime_core::Error::Config(format!("invalid linode tier: {s}"))
}
Error::Serde(e) => kei_runtime_core::Error::Provider(e.to_string()),
Error::Dna(e) => kei_runtime_core::Error::Dna(e),
Error::Other(s) => kei_runtime_core::Error::Other(s),
}
}
}