Skip to content

Commit

Permalink
error: Distinguish toml parsing errors from "manifest not found"
Browse files Browse the repository at this point in the history
While implementing #12 an invalid `.cargo/config.toml` turned into an
undescriptive and incorrect `ManifestNotFound` here.  Forwarding the
parsing error gives the user a much more descriptive error message
that'll help understand what to fix.
  • Loading branch information
MarijnS95 committed Mar 3, 2022
1 parent 421131a commit dd765d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub enum Error {
RustcNotFound,
Io(IoError),
GlobPatternError(&'static str),
Toml(TomlError),
}

impl Display for Error {
Expand All @@ -20,6 +21,7 @@ impl Display for Error {
Self::RustcNotFound => "Didn't find rustc.",
Self::Io(error) => return error.fmt(f),
Self::GlobPatternError(error) => error,
Self::Toml(error) => return error.fmt(f),
};
write!(f, "{}", msg)
}
Expand All @@ -34,8 +36,8 @@ impl From<IoError> for Error {
}

impl From<TomlError> for Error {
fn from(_error: TomlError) -> Self {
Self::ManifestNotFound
fn from(error: TomlError) -> Self {
Self::Toml(error)
}
}

Expand Down

0 comments on commit dd765d1

Please sign in to comment.