square_rs/
error.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug)]
4pub struct SquareError;
5
6impl From<reqwest::Error> for SquareError {
7    fn from(r: reqwest::Error) -> Self {
8        eprintln!("Reqwest Failed: {:?}", r);
9        SquareError
10    }
11}
12
13impl From<reqwest::header::InvalidHeaderValue> for SquareError {
14    fn from(r: reqwest::header::InvalidHeaderValue) -> Self {
15        eprintln!("Reqwest Header Failed: {:?}", r);
16        SquareError
17    }
18}
19
20impl From<serde_json::Error> for SquareError {
21    fn from(s: serde_json::Error) -> Self {
22        eprintln!("Serde JSON Failed: {:?}", s);
23        SquareError
24    }
25}
26
27#[derive(Serialize, Deserialize, Debug)]
28pub struct PaymentError {
29    code: PaymentErrorCode,
30    category: PaymentErrorCategory,
31}
32
33#[derive(Serialize, Deserialize, Debug)]
34#[non_exhaustive]
35pub enum PaymentErrorCode {
36    // ADDRESS_VERIFICATION_FAILURE,
37    // CARDHOLDER_INSUFFICIENT_PERMISSIONS,
38    ErrorCode,
39}
40
41#[derive(Serialize, Deserialize, Debug)]
42pub enum PaymentErrorCategory {
43    PaymentErrorCat,
44}
45
46#[derive(Serialize, Deserialize, Debug)]
47pub struct PaymentBuildError;