aw_test/services/
exception.rs

1use std::fmt;
2use std::error::Error;
3
4#[derive(Debug, Clone, Deserialize)]
5pub struct AppwriteException {
6    pub message: String,
7    pub code: i32,
8    pub version: String
9}
10
11impl fmt::Display for AppwriteException {
12    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13        write!(f,"ERROR: '{}' CODE: {}", self.message, self.code)
14    }
15}
16
17impl Error for AppwriteException {
18    fn description(&self) -> &str {
19        &self.message
20    }
21}
22
23impl AppwriteException {
24    pub fn new(message: String, code: i32, version: String) -> Self {
25        Self {
26            message: message,
27            code: code,
28            version: version
29        }
30    }
31}