Skip to content

Commit

Permalink
Add author and improve entry repack errors
Browse files Browse the repository at this point in the history
  • Loading branch information
szeweq committed Sep 29, 2023
1 parent d2b5ae9 commit 1b5aa8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/bin/mc-repack/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod cli_args;

fn main() -> io::Result<()> {
let args = cli_args::Args::parse();
println!("█▀▄▀█ █▀▀ ▄▄ █▀█ █▀▀ █▀█ ▄▀█ █▀▀ █▄▀\n█ ▀ █ █▄▄ █▀▄ ██▄ █▀▀ █▀█ █▄▄ █ █\n");
println!("█▀▄▀█ █▀▀ ▄▄ █▀█ █▀▀ █▀█ ▄▀█ █▀▀ █▄▀\n█ ▀ █ █▄▄ █▀▄ ██▄ █▀▀ █▀█ █▄▄ █ █ by Szeweq\n");
process_task_from(args)
}

Expand Down Expand Up @@ -167,9 +167,9 @@ fn thread_progress_bar(pb: ProgressBar) -> (JoinHandle<()>, Sender<ProgressState

fn print_entry_errors(v: &[EntryRepackError]) {
if !v.is_empty() {
eprintln!("Errors found in file entries:");
eprintln!("Errors found in files:");
for ere in v {
eprintln!(" # {}: {}", ere.name, ere.source().map_or("no error".to_string(), |e| e.to_string()));
eprintln!(" # {ere}");
}
}
}
10 changes: 8 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ pub struct EntryRepackError {
pub name: Box<str>,
inner: Box<dyn Error>
}
impl EntryRepackError {
/// Returns the inner error.
pub fn inner_error(&self) -> &dyn Error {
&*self.inner
}
}
impl Error for EntryRepackError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
Some(&*self.inner)
}
}
impl Display for EntryRepackError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name)
write!(f, "{}: {}", self.name, self.inner)
}
}

Expand All @@ -56,6 +62,6 @@ pub struct BlacklistedFile;
impl Error for BlacklistedFile {}
impl Display for BlacklistedFile {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Blacklisted")
f.write_str("Blacklisted")
}
}

0 comments on commit 1b5aa8f

Please sign in to comment.