Skip to content

Commit 62ecfea

Browse files
committed
Improve error formatting
1 parent 11c32bd commit 62ecfea

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

generator/src/error.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
use std::path::PathBuf;
2+
13
#[derive(Debug)]
24
pub enum Error {
35
CloneFail(git2::Error),
46
IO(std::io::Error),
5-
InvalidDatePrefix,
6-
NoDateInOrgReport,
7+
InvalidDatePrefix(PathBuf, String),
8+
NoDateInOrgReport(PathBuf),
79
}
810

911
impl From<git2::Error> for Error {

generator/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ fn main() -> Result<(), Error> {
2020
let reports_org_path = reports::clone(cli.reports)?;
2121
let reports_org_list = reports::find(reports_org_path)?;
2222
for report in reports_org_list {
23-
let report_md = reports::convert(report, &cli.website)?;
23+
match reports::convert(report, &cli.website) {
24+
Ok(report_md) => {},
25+
Err(e) => eprintln!("{:?}", e),
26+
};
2427
}
2528
Ok(())
2629
}

generator/src/reports.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ fn get_date(report_org_path: &Path) -> Result<String, Error> {
3333
let date = line
3434
.split(':')
3535
.nth(1)
36-
.ok_or(Error::InvalidDatePrefix)?
36+
.ok_or(Error::InvalidDatePrefix(report_org_path.to_path_buf(), line.to_string()))?
3737
.trim()
3838
.to_string();
3939
return Ok(date);
4040
}
4141
}
42-
Err(Error::NoDateInOrgReport)
42+
Err(Error::NoDateInOrgReport(report_org_path.to_path_buf()))
4343
}
4444

4545
pub fn convert(report_org_path: PathBuf, website: &Path) -> Result<PathBuf, Error> {

0 commit comments

Comments
 (0)