wasmium_errors/
lib.rs

1#![no_std]
2#![deny(missing_docs)]
3//! This module is a collection of common errors
4//! used throughout the Wasmium Ecosystem of Rust crates.
5//! It's goal is to avoid repetition of error handling
6
7/// A wrapper around `core::result::Result<T, WasmiumError>`
8pub type WasmiumResult<T> = core::result::Result<T, WasmiumError>;
9
10/// Error handling enum
11#[derive(Debug, Clone)]
12pub enum WasmiumError {
13    /// An error was encountered when trying to encrypt given bytes
14    /// using `XChaCha8Poly1305`
15    XChaCha8Poly1305EncryptionError = 0x01,
16    /// An error was encountered when trying to decrypt given bytes
17    /// using `XChaCha8Poly1305`
18    XChaCha8Poly1305DecryptionError = 0x02,
19    /// Unable to create `KeyPair` from bytes
20    InvalidBytesForKeyPair = 0x03,
21    /// Encountered an error when signing the message
22    SigningError = 0x04,
23    /// Unable to decode public key from provided base58 String
24    InvalidBase58ForPublickKey = 0x05,
25    /// Unable to convert the provided data into a `[u8; 32]
26    ErrorConvertingToU832 = 0x06,
27    /// Keeper Public Key Already Exists,
28    KeeperExists = 0x07,
29    /// Arbitrator Public Key Already Exists,
30    ArbitratorExists = 0x08,
31    /// The keeper storage is full
32    KeeperStorageFull = 0x09,
33    /// The keeper storage is full
34    ArbitratorStorageFull = 0x10,
35    /// Could not deserialize Solana `PDA` account data
36    PdaDeserializationError = 0x0a,
37    /// Error writing result to PDA buffer
38    WriteToPdaError,
39    /// The instruction sent is not implemented yet
40    KeeperInstructionNotImplemented,
41    /// Error deserializing the `KeeperInstruction`
42    KeeperInstructionDeserError,
43    /// Unable to create `ed25519_dalek::PublicKey` from bytes
44    InvalidBytesForPublicKey,
45    /// An error that could not be handled by the current state
46    Unspecified = 0xff,
47}
48/*FIXME
49impl From<usize> for WasmiumError {
50    fn from(value: usize) -> Self {
51        match value {
52            0x01 => WasmiumError::XChaCha8Poly1305EncryptionError,
53            0x02 => WasmiumError::XChaCha8Poly1305DecryptionError,
54            0x03 => WasmiumError::InvalidBytesForKeyPair,
55            0x04 => WasmiumError::SigningError,
56            0x05 => WasmiumError::InvalidBase58ForPublickKey,
57            0x06 => WasmiumError::ErrorConvertingToU832,
58            0x07 => WasmiumError::KeeperExists,
59            0x08 => WasmiumError::ArbitratorExists,
60            _ => WasmiumError::Unspecified,
61        }
62    }
63}
64*/