Files
wasmeld/crates/wasmeld-runtime/src/error.rs
T
Maofeng 53a8c6b690 feat(runtime): cache compiled components
Enable Wasmtime's persistent compilation cache and expose an optional cache directory in RuntimeConfig.

Create and canonicalize the configured directory before Engine construction, and report cache filesystem and configuration failures through dedicated RuntimeError variants.
2026-07-30 07:18:21 +08:00

95 lines
2.7 KiB
Rust

//! Runtime error taxonomy exposed to management layers.
use std::{path::PathBuf, time::Duration};
use thiserror::Error;
use crate::manifest::ServiceKey;
/// Failures from Runtime configuration, sandbox validation, or Actor execution.
#[derive(Debug, Error)]
pub enum RuntimeError {
#[error("service id and revision must not be empty")]
InvalidServiceKey,
#[error("invalid manifest: {0}")]
InvalidManifest(String),
#[error("manifest parse failed: {0}")]
ManifestParse(#[from] toml::de::Error),
#[error("service revision {0} is not registered")]
ServiceNotRegistered(ServiceKey),
#[error("service revision {0} is already registered")]
ServiceAlreadyRegistered(ServiceKey),
#[error("component compilation failed: {0}")]
ComponentCompilation(#[source] wasmtime::Error),
#[error("component imports unsupported capability {0}")]
UnsupportedImport(String),
#[error("component requires unavailable capability {0}")]
CapabilityUnavailable(String),
#[error("runtime creation failed: {0}")]
RuntimeCreation(#[source] wasmtime::Error),
#[error("failed to prepare Component compilation cache {path}: {source}")]
CacheDirectory {
path: PathBuf,
#[source]
source: std::io::Error,
},
#[error("invalid Component compilation cache configuration: {0}")]
CacheConfiguration(#[source] wasmtime::Error),
#[error("failed to read component artifact {path}: {source}")]
ArtifactRead {
path: String,
#[source]
source: std::io::Error,
},
#[error("failed to spawn actor thread: {0}")]
ActorThread(#[source] std::io::Error),
#[error("actor initialization failed: {0}")]
ActorInitialization(String),
#[error("actor for {0} is unavailable")]
ActorUnavailable(ServiceKey),
#[error("actor mailbox for {0} is full")]
ActorOverloaded(ServiceKey),
#[error("actor for {0} stopped before returning a result")]
ActorStopped(ServiceKey),
#[error("input for {service} exceeds the {limit}-byte limit")]
InputTooLarge { service: ServiceKey, limit: usize },
#[error("output for {service} exceeds the {limit}-byte limit")]
OutputTooLarge { service: ServiceKey, limit: usize },
#[error("actor for {service} exceeded its {deadline:?} execution deadline")]
DeadlineExceeded {
service: ServiceKey,
deadline: Duration,
},
#[error("actor for {service} faulted: {message}")]
ActorFault {
service: ServiceKey,
message: String,
},
#[error("component returned {kind}: {message}")]
ComponentError { kind: &'static str, message: String },
#[error("runtime lock was poisoned")]
LockPoisoned,
}