My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/development/tools/cargo-workspace2/src/cargo/error.rs

42 lines
1.0 KiB

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
}
}