bye snafu

This commit is contained in:
Lucien Greathouse
2020-03-16 23:37:00 -07:00
parent c065ded440
commit aa4039a2e7
3 changed files with 18 additions and 20 deletions

1
Cargo.lock generated
View File

@@ -1705,7 +1705,6 @@ dependencies = [
"serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)", "serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)",
"snafu 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"structopt 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)", "structopt 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@@ -89,7 +89,6 @@ ritz = "0.1.0"
rlua = "0.17.0" rlua = "0.17.0"
serde = { version = "1.0", features = ["derive", "rc"] } serde = { version = "1.0", features = ["derive", "rc"] }
serde_json = "1.0" serde_json = "1.0"
snafu = "0.6.0"
structopt = "0.3.5" structopt = "0.3.5"
termcolor = "1.0.5" termcolor = "1.0.5"
thiserror = "1.0.11" thiserror = "1.0.11"

View File

@@ -6,22 +6,26 @@ use std::{
use rbx_dom_weak::UnresolvedRbxValue; use rbx_dom_weak::UnresolvedRbxValue;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use snafu::{ResultExt, Snafu}; use thiserror::Error;
use crate::glob::Glob; use crate::glob::Glob;
static PROJECT_FILENAME: &str = "default.project.json"; static PROJECT_FILENAME: &str = "default.project.json";
/// Error type returned by any function that handles projects. /// Error type returned by any function that handles projects.
#[derive(Debug, Snafu)] #[derive(Debug, Error)]
pub struct ProjectError(Error); #[error(transparent)]
pub struct ProjectError(#[from] Error);
#[derive(Debug, Snafu)] #[derive(Debug, Error)]
enum Error { enum Error {
/// A general IO error occurred. #[error("Rojo project I/O error")]
Io { source: io::Error, path: PathBuf }, Io {
#[from]
source: io::Error,
},
/// An error with JSON parsing occurred. #[error("Error parsing Rojo project")]
Json { Json {
source: serde_json::Error, source: serde_json::Error,
path: PathBuf, path: PathBuf,
@@ -125,14 +129,14 @@ impl Project {
} }
} }
fn load_exact(project_file_location: &Path) -> Result<Self, ProjectError> { fn load_exact(project_file_location: &Path) -> Result<Self, Error> {
let contents = fs::read_to_string(project_file_location).context(Io { let contents = fs::read_to_string(project_file_location)?;
path: project_file_location,
})?;
let mut project: Project = serde_json::from_str(&contents).context(Json { let mut project: Project =
path: project_file_location, serde_json::from_str(&contents).map_err(|source| Error::Json {
})?; source,
path: project_file_location.to_owned(),
})?;
project.file_location = project_file_location.to_path_buf(); project.file_location = project_file_location.to_path_buf();
project.check_compatibility(); project.check_compatibility();
@@ -140,10 +144,6 @@ impl Project {
Ok(project) Ok(project)
} }
pub fn save(&self) -> Result<(), ProjectError> {
unimplemented!()
}
/// Checks if there are any compatibility issues with this project file and /// Checks if there are any compatibility issues with this project file and
/// warns the user if there are any. /// warns the user if there are any.
fn check_compatibility(&self) { fn check_compatibility(&self) {