mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 05:35:10 +00:00
Drop SnapshotError in favor of anyhow::Error
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use std::{path::Path, str};
|
||||
|
||||
use anyhow::Context;
|
||||
use maplit::hashmap;
|
||||
use memofs::{IoResultExt, Vfs};
|
||||
use rbx_dom_weak::RbxValue;
|
||||
@@ -28,9 +29,8 @@ pub fn snapshot_lua(context: &InstanceContext, vfs: &Vfs, path: &Path) -> Snapsh
|
||||
|
||||
let contents = vfs.read(path)?;
|
||||
let contents_str = str::from_utf8(&contents)
|
||||
// TODO: Turn into error type
|
||||
.expect("File content was not valid UTF-8")
|
||||
.to_string();
|
||||
.with_context(|| format!("File was not valid UTF-8: {}", path.display()))?
|
||||
.to_owned();
|
||||
|
||||
let meta_path = path.with_file_name(format!("{}.meta.json", instance_name));
|
||||
|
||||
@@ -71,10 +71,14 @@ pub fn snapshot_lua_init(
|
||||
let dir_snapshot = snapshot_dir(context, vfs, folder_path)?.unwrap();
|
||||
|
||||
if dir_snapshot.class_name != "Folder" {
|
||||
panic!(
|
||||
anyhow::bail!(
|
||||
"init.lua, init.server.lua, and init.client.lua can \
|
||||
only be used if the instance produced by the parent \
|
||||
directory would be a Folder."
|
||||
only be used if the instance produced by the containing \
|
||||
directory would be a Folder.\n\n\
|
||||
|
||||
The directory {} turned into an instance of class {}.",
|
||||
folder_path.display(),
|
||||
dir_snapshot.class_name
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user