summaryrefslogtreecommitdiffstats
path: root/crates/core/c8y_smartrest/src/error.rs
blob: 03fd51256ef5f2c9d6c8a7bb746703caaec7d0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use json_sm::SoftwareUpdateResponse;

#[derive(thiserror::Error, Debug)]
pub enum SmartRestSerializerError {
    #[error("The operation status is not supported. {response:?}")]
    UnsupportedOperationStatus { response: SoftwareUpdateResponse },

    #[error("Failed to serialize SmartREST.")]
    InvalidCsv(#[from] csv::Error),

    #[error(transparent)]
    FromCsvWriter(#[from] csv::IntoInnerError<csv::Writer<Vec<u8>>>),

    #[error(transparent)]
    FromUtf8Error(#[from] std::string::FromUtf8Error),
}

#[derive(thiserror::Error, Debug)]
pub enum SmartRestDeserializerError {
    #[error("The received SmartREST message ID {id} is unsupported.")]
    UnsupportedOperation { id: String },

    #[error("Failed to deserialize SmartREST.")]
    InvalidCsv(#[from] csv::Error),

    #[error("Jwt response contains incorrect ID: {0}")]
    InvalidMessageId(u16),

    #[error("Parameter {parameter} is not recognized. {hint}")]
    InvalidParameter {
        operation: String,
        parameter: String,
        hint: String,
    },
}