-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patherror.rs
46 lines (39 loc) · 1.1 KB
/
error.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
37
38
39
40
41
42
43
44
45
46
//! This crate's error type.
use std::io;
/// Describes all errors from this crate.
///
/// - errors during parsing.
/// - errors reported other crates.
#[derive(thiserror::Error, Debug)]
pub enum Error {
/// Error parsing SocInfo.
#[error("socinfo parsing error: `{0}`")]
SocInfoParsingError(String),
/// Error parsing integer.
#[error("integer parsing error: `{source}`")]
ParseIntError {
#[from]
/// Source error.
source: std::num::ParseIntError,
},
/// Error parsing a plist.
#[error("plist parsing error: `{0}`")]
PlistParsingError(String),
/// Misalignment of CPU IDs between powermetrics and the sysinfo crate.
#[error("cpu id misalignment: `{0}`")]
MisalignedCpuId(String),
/// Error converting a string to utf8.
#[error("utf8 conversion error: `{source}`")]
Utf8ConversionError {
#[from]
/// Source error.
source: std::string::FromUtf8Error,
},
/// Some IO error.
#[error("failed with io: `{source}`")]
Io {
#[from]
/// Source error.
source: io::Error,
},
}