Drop SnapshotError in favor of anyhow::Error

This commit is contained in:
Lucien Greathouse
2020-12-18 12:16:05 -08:00
parent f3745c68d2
commit 3b149cc875
15 changed files with 70 additions and 183 deletions

View File

@@ -1,5 +1,6 @@
use std::{borrow::Cow, collections::HashMap, path::Path};
use anyhow::Context;
use memofs::Vfs;
use rbx_dom_weak::UnresolvedRbxValue;
use rbx_reflection::try_resolve_value;
@@ -7,7 +8,7 @@ use serde::Deserialize;
use crate::snapshot::{InstanceContext, InstanceSnapshot};
use super::{error::SnapshotError, middleware::SnapshotInstanceResult};
use super::middleware::SnapshotInstanceResult;
pub fn snapshot_json_model(
context: &InstanceContext,
@@ -17,7 +18,7 @@ pub fn snapshot_json_model(
) -> SnapshotInstanceResult {
let contents = vfs.read(path)?;
let instance: JsonModel = serde_json::from_slice(&contents)
.map_err(|source| SnapshotError::malformed_model_json(source, path))?;
.with_context(|| format!("File is not a valid JSON model: {}", path.display()))?;
let mut snapshot = instance.core.into_snapshot(instance_name.to_owned());