Skip to main content

tauri_plugin_auditaur/
error.rs

1use serde::Serialize;
2use std::fmt::{Display, Formatter};
3
4#[derive(Debug, Serialize)]
5pub struct AuditaurError {
6    message: String,
7}
8
9impl AuditaurError {
10    pub fn new(message: impl Into<String>) -> Self {
11        Self {
12            message: message.into(),
13        }
14    }
15}
16
17impl Display for AuditaurError {
18    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
19        write!(f, "{}", self.message)
20    }
21}
22
23impl std::error::Error for AuditaurError {}
24
25impl From<auditaur_collector::exporter_sqlite::SqliteStoreError> for AuditaurError {
26    fn from(value: auditaur_collector::exporter_sqlite::SqliteStoreError) -> Self {
27        Self::new(value.to_string())
28    }
29}
30
31impl From<std::io::Error> for AuditaurError {
32    fn from(value: std::io::Error) -> Self {
33        Self::new(value.to_string())
34    }
35}
36
37impl From<serde_json::Error> for AuditaurError {
38    fn from(value: serde_json::Error) -> Self {
39        Self::new(value.to_string())
40    }
41}