Skip to main content

freenet_stdlib/contract_interface/
error.rs

1//! Error types for contract interface operations.
2
3use serde::{Deserialize, Serialize};
4
5/// Type of errors during interaction with a contract.
6///
7/// Marked `#[non_exhaustive]` so future error variants can be added without
8/// a source-level break. Downstream `match` sites must include a wildcard arm.
9#[non_exhaustive]
10#[derive(Debug, thiserror::Error, Serialize, Deserialize)]
11pub enum ContractError {
12    #[error("de/serialization error: {0}")]
13    Deser(String),
14    #[error("invalid contract update")]
15    InvalidUpdate,
16    #[error("invalid contract update, reason: {reason}")]
17    InvalidUpdateWithInfo { reason: String },
18    #[error("trying to read an invalid state")]
19    InvalidState,
20    #[error("trying to read an invalid delta")]
21    InvalidDelta,
22    #[error("{0}")]
23    Other(String),
24}