shadow_drive_sdk/
error.rs1use anchor_lang::error::Error as AnchorError;
2use reqwest::Error as ReqwestError;
3use solana_client::client_error::ClientError;
4use solana_sdk::pubkey::ParsePubkeyError;
5use solana_sdk::signer::SignerError;
6use std::io::Error as IoError;
7use tokio::task::JoinError;
8
9#[derive(Debug)]
10pub enum Error {
11 ShadowDriveServerError {
12 status: u16,
13 message: serde_json::Value,
14 },
15 FileTooLarge(String),
16 TransactionSerializationFailed(String),
17 InvalidJson(serde_json::Error),
18 SolanaRpcError(ClientError),
19 AccountDeserializeError(IoError),
20 InvalidStorage,
21 SignerError(SignerError),
22 AnchorError(AnchorError),
23 ReqwestError(ReqwestError),
24 AsyncJoinError(JoinError),
25 FileValidationError(Vec<FileError>),
26 UserInfoNotCreated,
27 FileSystemError(std::io::Error),
28 ParsePubkeyError(ParsePubkeyError),
29 NotFileOwner,
30 StorageAccountIsNotImmutable,
31}
32
33#[derive(Debug)]
34pub struct FileError {
35 pub file: String,
36 pub error: String,
37}
38
39impl From<JoinError> for Error {
40 fn from(join_error: JoinError) -> Self {
41 Self::AsyncJoinError(join_error)
42 }
43}
44
45impl From<ClientError> for Error {
46 fn from(client_error: ClientError) -> Self {
47 Self::SolanaRpcError(client_error)
48 }
49}
50
51impl From<SignerError> for Error {
52 fn from(signer_error: SignerError) -> Self {
53 Self::SignerError(signer_error)
54 }
55}
56
57impl From<AnchorError> for Error {
58 fn from(anchor_error: AnchorError) -> Self {
59 Self::AnchorError(anchor_error)
60 }
61}
62
63impl From<ReqwestError> for Error {
64 fn from(signer_error: ReqwestError) -> Self {
65 Self::ReqwestError(signer_error)
66 }
67}
68
69impl From<ParsePubkeyError> for Error {
70 fn from(parse_pubkey_error: ParsePubkeyError) -> Self {
71 Self::ParsePubkeyError(parse_pubkey_error)
72 }
73}
74
75impl From<std::io::Error> for Error {
76 fn from(e: std::io::Error) -> Self {
77 Self::FileSystemError(e)
78 }
79}