Fix malformed meta files causing panics.

Fixes #280.
This commit is contained in:
Lucien Greathouse
2020-03-13 20:38:06 -07:00
parent 6de74b41b3
commit 1cbe272e19
6 changed files with 25 additions and 15 deletions

View File

@@ -63,6 +63,13 @@ impl SnapshotError {
path: Some(path.into()),
}
}
pub(crate) fn malformed_meta_json(source: serde_json::Error, path: impl Into<PathBuf>) -> Self {
Self {
detail: SnapshotErrorDetail::MalformedMetaJson { source },
path: Some(path.into()),
}
}
}
impl Error for SnapshotError {
@@ -114,6 +121,9 @@ pub enum SnapshotErrorDetail {
#[snafu(display("malformed .model.json file"))]
MalformedModelJson { source: serde_json::Error },
#[snafu(display("malformed .meta.json file"))]
MalformedMetaJson { source: serde_json::Error },
}
impl From<io::Error> for SnapshotErrorDetail {