Skip to main content

openstranded_common_wasmcontract/
error.rs

1use thiserror::Error;
2
3/// Errors that occur during Service API calls or Registry access.
4///
5/// All variants are Clone + Debug for passing across the WASM boundary.
6#[derive(Clone, Debug, Error)]
7pub enum ServiceError {
8    /// An argument did not match the expected type.
9    #[error("invalid arguments: expected {expected}, got {found}")]
10    TypeMismatch {
11        expected: String,
12        found: String,
13    },
14
15    /// Method not found on the service.
16    #[error("unknown method: {0}")]
17    UnknownMethod(String),
18
19    /// Service domain is not registered.
20    #[error("service domain not found: {0}")]
21    DomainNotFound(String),
22
23    /// File not found in Registry at domain/filename.
24    #[error("file not found in registry: {domain}/{filename}")]
25    FileNotFound {
26        domain: String,
27        filename: String,
28    },
29
30    /// Registry domain not found.
31    #[error("registry domain not found: {0}")]
32    RegistryDomainNotFound(String),
33
34    /// Error parsing registry data (RON / JSON / binary).
35    #[error("parse error: {0}")]
36    ParseError(String),
37
38    /// Internal / generic error.
39    #[error("internal error: {0}")]
40    Internal(String),
41}