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    /// Entity not found in the ECS world.
35    #[error("entity not found: {0}")]
36    EntityNotFound(u64),
37
38    /// Component not found on entity.
39    #[error("component '{type_name}' not found on entity {entity}")]
40    ComponentNotFound {
41        entity: u64,
42        type_name: String,
43    },
44
45    /// Content file not found by path.
46    #[error("content file not found: {0}")]
47    ContentFileNotFound(String),
48
49    /// Error parsing registry data (RON / JSON / binary).
50    #[error("parse error: {0}")]
51    ParseError(String),
52
53    /// Internal / generic error.
54    #[error("internal error: {0}")]
55    Internal(String),
56}