microsandbox_types/error.rs
1//! Error types for shared microsandbox contracts.
2
3//--------------------------------------------------------------------------------------------------
4// Types
5//--------------------------------------------------------------------------------------------------
6
7/// The result type for shared microsandbox contract operations.
8pub type TypesResult<T> = Result<T, TypesError>;
9
10/// Errors returned by shared microsandbox contract helpers.
11#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
12pub enum TypesError {
13 /// A supplied configuration value is invalid.
14 #[error("invalid config: {0}")]
15 InvalidConfig(String),
16}
17
18/// The result type for snapshot descriptor operations.
19pub type SnapshotManifestResult<T> = Result<T, SnapshotManifestError>;
20
21/// Errors returned by snapshot descriptor parsing, validation, and canonical
22/// serialization.
23#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
24pub enum SnapshotManifestError {
25 /// Snapshot descriptor bytes or fields violate the schema contract.
26 #[error("manifest parse error: {0}")]
27 ManifestParse(String),
28}
29
30//--------------------------------------------------------------------------------------------------
31// Methods
32//--------------------------------------------------------------------------------------------------
33
34impl TypesError {
35 pub(crate) fn invalid_config(message: impl Into<String>) -> Self {
36 Self::InvalidConfig(message.into())
37 }
38}