From 67d771fc3a954ea439e77afac092c84c5489d074 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Tue, 12 Mar 2019 19:23:22 +0100 Subject: Added some error messages + reworked the print_error_chain method --- src/listing.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/listing.rs') diff --git a/src/listing.rs b/src/listing.rs index ab3b28b..a9f0f19 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -7,7 +7,7 @@ use serde::Deserialize; use std::io; use std::path::Path; use std::time::SystemTime; -use yansi::{Color, Paint}; +use yansi::Color; use crate::archive; use crate::errors; @@ -238,8 +238,9 @@ pub fn directory_listing( match archive::create_archive_file(&compression_method, &dir.path) { Ok((filename, content)) => { println!( - "{success} Archive successfully created !", - success = Color::Green.paint("success:").bold() + "{success} {file} successfully created !", + success = Color::Green.paint("success:").bold(), + file = Color::White.paint(&filename).bold(), ); Ok(HttpResponse::Ok() .content_type(compression_method.content_type()) @@ -254,12 +255,7 @@ pub fn directory_listing( .body(Body::Streaming(Box::new(once(Ok(content)))))) } Err(err) => { - println!( - "{error} {err}", - error = Paint::red("error:").bold(), - err = Paint::white(&err).bold() - ); - errors::print_chain(err); + errors::print_error_chain(err); Ok(HttpResponse::Ok() .status(http::StatusCode::INTERNAL_SERVER_ERROR) .body("")) -- cgit v1.2.3