ih_muse_core/
errors.rs

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
36
// crates/ih-muse-core/src/errors.rs

use std::time::Duration;

use chrono::OutOfRangeError;
use thiserror::Error;

pub type MuseResult<T> = Result<T, MuseError>;

#[derive(Error, Debug)]
pub enum MuseError {
    #[error("Configuration error {0}")]
    Configuration(String),
    #[error("Network error occurred")]
    Client(String),
    #[error("Muse initialization timeout {0:?}")]
    MuseInitializationTimeout(Duration),
    #[error("Recording error {0}")]
    Recording(String),
    #[error("Replaying error {0}")]
    Replaying(String),
    #[error("File has an invalid extension {0:?}")]
    InvalidFileExtension(Option<String>),
    #[error("Invalid Element Kind Code {0}")]
    InvalidElementKindCode(String),
    #[error("Invalid Metric Code {0}")]
    InvalidMetricCode(String),
    #[error("Duration conversion error: {0}")]
    DurationConversion(String),
}

impl From<OutOfRangeError> for MuseError {
    fn from(err: OutOfRangeError) -> Self {
        MuseError::DurationConversion(err.to_string())
    }
}