-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
52 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,15 @@ | ||
/// Custom error type | ||
#[derive(Debug)] | ||
pub enum Error { | ||
/// Sourcecode could be located | ||
SourceCodeNotFound, | ||
/// Git is not installed or did not function properly | ||
GitNotInstalled, | ||
/// Did not find any git data in the directory | ||
NoGitData, | ||
/// An IO error occoured while reading ./ | ||
ReadDirectory, | ||
/// Not in a Git Repo | ||
NotGitRepo, | ||
/// Error while getting branch info | ||
BareGitRepo, | ||
/// Repository is a bare git repo | ||
ReferenceInfoError, | ||
/// Image probably doesn't exist or has wrong format | ||
ImageLoadError, | ||
/// Could not initialize the license detector | ||
LicenseDetectorError, | ||
} | ||
use colored::Colorize; | ||
use error_chain::error_chain; | ||
use std::io::Write; | ||
|
||
impl std::fmt::Display for Error { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
let content = match self { | ||
Error::SourceCodeNotFound => "Could not find any source code in this directory", | ||
Error::GitNotInstalled => "Git failed to execute", | ||
Error::NoGitData => "Could not retrieve git configuration data", | ||
Error::ReadDirectory => "Could not read directory", | ||
Error::NotGitRepo => "Could not find a valid git repo on the current path", | ||
Error::BareGitRepo => "Unable to run onefetch on bare git repos", | ||
Error::ReferenceInfoError => "Error while retrieving reference information", | ||
Error::ImageLoadError => "Could not load the specified image", | ||
Error::LicenseDetectorError => "Could not initialize the license detector", | ||
}; | ||
write!(f, "{}", content) | ||
error_chain! { | ||
foreign_links { | ||
Clap(::clap::Error) #[cfg(feature = "application")]; | ||
Io(::std::io::Error); | ||
ParseIntError(::std::num::ParseIntError); | ||
} | ||
} | ||
|
||
pub fn default_error_handler(error: &Error, output: &mut dyn Write) { | ||
writeln!(output, "{}: {}", "[onefetch error]".red(), error).ok(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters