supabase_function_rs/
errors.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum FunctionsError {
5    FetchError(String),
6    HttpError(String),
7    RelayError(String),
8}
9
10impl fmt::Display for FunctionsError {
11    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12        match self {
13            FunctionsError::FetchError(msg) => write!(f, "FetchError: {}", msg),
14            FunctionsError::HttpError(msg) => write!(f, "HttpError: {}", msg),
15            FunctionsError::RelayError(msg) => write!(f, "RelayError: {}", msg),
16        }
17    }
18}
19
20impl std::error::Error for FunctionsError {}
21
22pub struct FunctionsFetchError;
23
24impl FunctionsFetchError {
25    pub fn new(context: String) -> FunctionsError {
26        FunctionsError::FetchError(context)
27    }
28}
29
30pub struct FunctionsRelayError;
31
32impl FunctionsRelayError {
33    pub fn new(context: String) -> FunctionsError {
34        FunctionsError::RelayError(context)
35    }
36}
37
38pub struct FunctionsHttpError;
39
40impl FunctionsHttpError {
41    pub fn new(context: String) -> FunctionsError {
42        FunctionsError::HttpError(context)
43    }
44}