Skip to main content

swig_sdk/
error.rs

1use thiserror::Error;
2
3/// Errors that can occur when using the Swig wallet SDK.
4#[derive(Error, Debug)]
5pub enum SwigError {
6    #[error("Invalid authority type provided")]
7    InvalidAuthorityType,
8
9    #[error("Base58 decode error: {0}")]
10    Base58DecodeError(#[from] bs58::decode::Error),
11
12    #[error("Interface error: {0}")]
13    InterfaceError(String),
14
15    #[error("Invalid swig data")]
16    InvalidSwigData,
17
18    #[error("Authority not found")]
19    AuthorityNotFound,
20
21    #[error("Invalid swig account discriminator")]
22    InvalidSwigAccountDiscriminator,
23
24    #[error("Invalid permission type: {0}")]
25    InvalidPermission(u8),
26
27    #[error("Invalid secp256k1 signature")]
28    InvalidSecp256k1,
29
30    #[error("Current slot not set")]
31    CurrentSlotNotSet,
32
33    #[error("Swig data not found")]
34    SwigDataNotFound,
35
36    #[error("Invalid program scope")]
37    InvalidProgramScope,
38
39    #[error("Counter not set")]
40    CounterNotSet,
41
42    #[error("Slot is required for this operation")]
43    SlotRequired,
44
45    #[error("Data too short: expected {expected} bytes, got {actual}")]
46    DataTooShort { expected: usize, actual: usize },
47
48    #[error("Role not found: {0}")]
49    RoleNotFound(u32),
50
51    #[error("Invalid update operation: {0}")]
52    InvalidUpdateOperation(u8),
53
54    #[cfg(feature = "rpc")]
55    #[error("Message compilation error: {0}")]
56    MessageCompilationError(String),
57
58    #[cfg(feature = "rpc")]
59    #[error("Transaction error: {0}")]
60    TransactionError(String),
61
62    #[cfg(feature = "rpc")]
63    #[error("Transaction failed: {error}\nLogs:\n{}", logs.join("\n"))]
64    TransactionFailedWithLogs { error: String, logs: Vec<String> },
65}