Skip to content
This repository was archived by the owner on Apr 29, 2024. It is now read-only.

Commit a5259fe

Browse files
committed
Use miette for fancy error reporting
1 parent 46e3def commit a5259fe

File tree

5 files changed

+213
-81
lines changed

5 files changed

+213
-81
lines changed

Cargo.lock

Lines changed: 168 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/kbcheck/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
jsonschema="0.16"
10+
miette={ version="5", features = ["fancy"] }
1011
serde="1"
1112
serde_json="1"
1213
serde_yaml="0.8"

tools/kbcheck/src/data.rs

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::entry::Entry;
2+
use miette::Diagnostic;
23
use std::collections::BTreeMap;
34
use std::fs::File;
45
use std::io;
@@ -9,32 +10,16 @@ use walkdir::{self, DirEntry, WalkDir};
910

1011
pub type EntriesMap = BTreeMap<PathBuf, Entry>;
1112

12-
#[derive(thiserror::Error, Debug)]
13+
#[derive(thiserror::Error, Debug, Diagnostic)]
1314
pub enum DataError {
14-
#[error("Could not open file")]
15-
IoError(
16-
#[from]
17-
#[source]
18-
io::Error,
19-
),
20-
#[error("JSON parsing failed")]
21-
JsonParseError(
22-
#[from]
23-
#[source]
24-
serde_json::Error,
25-
),
26-
#[error("Loading YAML failed")]
27-
YamlLoadError(
28-
#[from]
29-
#[source]
30-
serde_yaml::Error,
31-
),
32-
#[error("JSON parsing failed")]
33-
WalkDirError(
34-
#[from]
35-
#[source]
36-
walkdir::Error,
37-
),
15+
#[error(transparent)]
16+
IoError(#[from] io::Error),
17+
#[error(transparent)]
18+
JsonParseError(#[from] serde_json::Error),
19+
#[error(transparent)]
20+
YamlLoadError(#[from] serde_yaml::Error),
21+
#[error(transparent)]
22+
WalkDirError(#[from] walkdir::Error),
3823
}
3924

4025
/// Read a path into a serde_json::Value

0 commit comments

Comments
 (0)