From 21b187927874a0ce312efeae545956e335cc41e7 Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Thu, 4 Mar 2021 09:32:39 +0800 Subject: [PATCH] fix: fix error handling issue --- Cargo.lock | 1 + Cargo.toml | 2 ++ src/app/analysis/cloc_analysis.rs | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3b303a2..c534c985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -669,6 +669,7 @@ dependencies = [ "clap", "core_model", "dialoguer", + "failure", "framework", "git2", "lazy_static", diff --git a/Cargo.toml b/Cargo.toml index 4a8883ec..80f5d9b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,8 @@ exclude = [ ] [dependencies] +failure = "0.1.8" + lazy_static = "1.4.0" # time format diff --git a/src/app/analysis/cloc_analysis.rs b/src/app/analysis/cloc_analysis.rs index 5960e1ba..54b47d93 100644 --- a/src/app/analysis/cloc_analysis.rs +++ b/src/app/analysis/cloc_analysis.rs @@ -1,6 +1,6 @@ use crate::domain::cloc::{ClocDetail, ClocLanguage}; use crate::infrastructure::cloc; -use std::error::Error; +use failure::Error; use std::path::{Path, PathBuf}; pub fn analysis(path: PathBuf) -> Vec { @@ -22,7 +22,7 @@ pub fn analysis(path: PathBuf) -> Vec { comments: report.stats.comments, file_name, path: strip_path.to_str().unwrap().to_string(), - bytes: file_size(strip_path).unwrap(), + bytes: file_size(&report.name).unwrap(), }); }