blob: cf4b7e3d1671521002d090df542b950b52e963d2 (
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
36
37
38
39
40
41
42
|
use std::{fmt, io};
use toml_edit::TomlError;
/// Errors occured while interacting with Cargo.toml files
#[derive(Debug)]
pub enum CargoError {
/// Failed to read or write a file
Io,
/// Error parsing Cargo.toml file
Parsing,
/// Provided Cargo.toml was no workspace
NoWorkspace,
/// Provided Cargo.toml had no dependencies
NoDependencies,
}
impl fmt::Display for CargoError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match self {
Self::Io => "General I/O error",
Self::Parsing => "Parsing error",
Self::NoWorkspace => "Selected crate root is not a workspace!",
Self::NoDependencies => "No dependencies found!",
}
)
}
}
impl From<io::Error> for CargoError {
fn from(_: io::Error) -> Self {
Self::Io
}
}
impl From<TomlError> for CargoError {
fn from(_: TomlError) -> Self {
Self::Parsing
}
}
|