easy_dynamodb/
error.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub enum DynamoException {
5    UnknownException(String),
6
7    // DynamoDB errors
8    DynamoSerializeException(String),
9    DynamoDeserializeException(String),
10    DynamoInvalidBookmark(String),
11    DynamoPutItemException(String),
12    DynamoUpdateItemException(String),
13    DynamoQueryException(String),
14    DynamoGetItemException(String),
15    DynamoDeleteItemException(String),
16    DynamoIncrementException(String),
17}
18
19impl std::fmt::Display for DynamoException {
20    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21        write!(f, "{:?}", self)
22    }
23}
24
25impl std::str::FromStr for DynamoException {
26    type Err = String;
27
28    fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
29        Ok(DynamoException::UnknownException(s.to_string()))
30    }
31}
32
33impl std::error::Error for DynamoException {
34    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
35        None
36    }
37}
38
39impl DynamoException {
40    pub fn to_string(&self) -> String {
41        format!("BaseError: {:?}", self)
42    }
43}
44
45unsafe impl Send for DynamoException {}
46unsafe impl Sync for DynamoException {}