algorand_rs/
error.rs

1extern crate derive_more;
2use derive_more::{Display, Error, From};
3use std::error;
4use std::fmt::Debug;
5
6pub type Result<T> = std::result::Result<T, Box<dyn error::Error>>;
7
8#[derive(Clone, Debug, Display, Error, From)]
9pub enum TokenParsingError {
10    /// Token has an invalid length.
11    #[display(fmt = "Token too short or too long.")]
12    InvalidLength,
13}
14
15#[derive(Clone, Debug, Display, Error, From)]
16pub enum AlgodBuildError {
17    /// URL parse error.
18    #[display(fmt = "Url parsing error.")]
19    BadUrl(url::ParseError),
20    /// Token parse error.
21    #[display(fmt = "Token parsing error.")]
22    BadToken(TokenParsingError),
23    /// Missing the base URL of the REST API server.
24    #[display(fmt = "Bind the client to URL before calling client().")]
25    UnitializedUrl,
26    /// Missing the authentication token for the REST API server.
27    #[display(fmt = "Authenticate with a token before calling client().")]
28    UnitializedToken,
29}
30
31#[derive(Debug, Display, Error, From)]
32pub struct ReqwestError(reqwest::Error);
33
34#[derive(Debug, Display, Error, From)]
35pub struct EncodeError(rmp_serde::encode::Error);
36
37#[derive(Debug, Display, Error, From)]
38pub struct JsonError(serde_json::Error);
39
40#[derive(Debug, Display, Error, From)]
41pub enum ApiError {
42    #[display(fmt = "Key length is invalid.")]
43    InvalidKeyLength,
44    #[display(fmt = "Mnemonic length is invalid.")]
45    InvalidMnemonicLength,
46    #[display(fmt = "Mnemonic contains invalid words.")]
47    InvalidWordsInMnemonic,
48    #[display(fmt = "Invalid checksum.")]
49    InvalidChecksum,
50    #[display(fmt = "Transaction sender does not match multisig identity.")]
51    InvalidSenderInMultisig,
52    #[display(fmt = "Multisig identity does not contain this secret key.")]
53    InvalidSecretKeyInMultisig,
54    #[display(fmt = "Can't merge only one transaction.")]
55    InsufficientTransactions,
56    #[display(fmt = "Multisig signatures to merge must have the same number of subsignatures.")]
57    InvalidNumberOfSubsignatures,
58    #[display(fmt = "Transaction msig public keys do not match.")]
59    InvalidPublicKeyInMultisig,
60    #[display(fmt = "Transaction msig has mismatched signatures.")]
61    MismatchingSignatures,
62    #[display(fmt = "Response error: {}", response)]
63    ResponseError { response: String },
64}