rs_sqs_receiver/
errors.rs1use std::str::FromStr;
2
3use thiserror::Error;
4
5#[derive(Debug, Error)]
10pub enum AwsSqsReceiverError {
11 #[error("failed to initialize AWS SQS client: {0}")]
16 InitializationError(String),
17
18 #[error("{0}")]
19 GenericError(#[from] GenericError),
20}
21
22#[derive(Debug, Error)]
24pub struct GenericError(String);
25
26impl GenericError {
27 pub fn new(message: String) -> Self {
29 GenericError(message)
30 }
31}
32
33impl std::fmt::Display for GenericError {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 write!(f, "{}", self.0)
36 }
37}
38
39impl FromStr for GenericError {
40 type Err = String;
41
42 fn from_str(s: &str) -> Result<Self, Self::Err> {
43 Ok(GenericError::new(s.to_string()))
44 }
45}
46
47impl From<String> for GenericError {
48 fn from(s: String) -> Self {
49 GenericError::new(s)
50 }
51}