diff options
Diffstat (limited to 'crates/core/c8y_smartrest/src/error.rs')
-rw-r--r-- | crates/core/c8y_smartrest/src/error.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/core/c8y_smartrest/src/error.rs b/crates/core/c8y_smartrest/src/error.rs new file mode 100644 index 00000000..03fd5125 --- /dev/null +++ b/crates/core/c8y_smartrest/src/error.rs @@ -0,0 +1,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, + }, +} |