postmark_client/errors.rs
1use reqwest::StatusCode;
2use thiserror::Error;
3
4use crate::types::APIError;
5
6/// Represents the types of errors that can be encountered
7#[derive(Error, Debug)]
8pub enum PostmarkClientError {
9 /// Postmark returned an unauthorized status
10 ///
11 /// <https://postmarkapp.com/developer/api/overview#response-codes>
12 #[error("unauthorized")]
13 Unauthorized,
14 /// Postmark returned a request to large status
15 ///
16 /// <https://postmarkapp.com/developer/api/overview#response-codes>
17 #[error("request exceeded postmarks size limit")]
18 RequestToLarge,
19 /// Postmark returned an unprossable entity status
20 ///
21 /// <https://postmarkapp.com/developer/api/overview#response-codes>
22 #[error("postmark was unable to process the request")]
23 UnprocessableEntity(APIError),
24 /// Postmark returned a rate limit exceeded status
25 ///
26 /// <https://postmarkapp.com/developer/api/overview#response-codes>
27 #[error("rate limit exceeded")]
28 RateLimitExceeded,
29 /// Postmark returned an internal server error status
30 ///
31 /// <https://postmarkapp.com/developer/api/overview#response-codes>
32 #[error("internal postmark server error")]
33 InternalServerError,
34 /// Postmark returned a service unavailable status
35 ///
36 /// <https://postmarkapp.com/developer/api/overview#response-codes>
37 #[error("postmark is currently unavailable")]
38 ServiceUnavailable,
39 /// Error from reqwest
40 #[error(transparent)]
41 Reqwest(#[from] reqwest::Error),
42 /// Postmark returned an unknown status
43 ///
44 /// <https://postmarkapp.com/developer/api/overview#response-codes>
45 #[error("unknown postmark status {0}")]
46 UnknownPostmarkStatus(StatusCode),
47}