1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use ion_binary_rs::IonParserError;
use rusoto_core::{request::TlsError, RusotoError};
use rusoto_qldb_session::SendCommandError;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum QLDBError {
    #[error("The QLDB command returned an error")]
    SendCommandError(#[from] RusotoError<SendCommandError>),
    #[error("We requested a session but QLDB returned nothing")]
    QLDBReturnedEmptySession,
    #[error("We requested a transaction id but QLDB returned nothing")]
    QLDBReturnedEmptyTransaction,
    // TODO: IonParserError seems to not be compatible
    // with "#[from]". Make it compatible
    #[error("We requested a transaction id but QLDB returned nothing")]
    IonParserError(IonParserError),
    #[error("Error when creating the HttpClient")]
    TlsError(#[from] TlsError),
    #[error("Transaction has been already commit or rollback")]
    TransactionCompleted,
    #[error("We weren't able to send the result value to ourselves. This is a bug.")]
    InternalChannelSendError,
    #[error("The statement provided to the count method didn't return what a normal SELECT COUNT(... would have returned.")]
    NonValidCountStatementResult,
    #[error("The transaction is already commited, it cannot be rollback")]
    TransactionAlreadyCommitted,
    #[error("The transaction is already rollback, it cannot be committed")]
    TransactionAlreadyRollback,
}

pub type QLDBResult<T> = Result<T, QLDBError>;