flutterwave_v3_models/
errors.rs1use std::fmt::Display;
2
3#[derive(Debug, thiserror::Error)]
4pub enum FWaveError {
5 SerDe(serde_json::Error),
6 Request(reqwest::Error),
7 RequestValidation(validator::ValidationErrors),
8}
9
10impl From<reqwest::Error> for FWaveError {
11 fn from(value: reqwest::Error) -> Self {
12 FWaveError::Request(value)
13 }
14}
15
16impl From<validator::ValidationErrors> for FWaveError {
17 fn from(value: validator::ValidationErrors) -> Self {
18 FWaveError::RequestValidation(value)
19 }
20}
21
22impl From<serde_json::Error> for FWaveError {
23 fn from(value: serde_json::Error) -> Self {
24 FWaveError::SerDe(value)
25 }
26}
27
28impl Display for FWaveError {
29 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30 match self {
31 FWaveError::SerDe(error) => f.write_str(&error.to_string()),
32 FWaveError::Request(error) => f.write_str(&error.to_string()),
33 FWaveError::RequestValidation(validation_errors) => {
34 f.write_str(&validation_errors.to_string())
35 }
36 }
37 }
38}