mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 15:16:07 +00:00
Start using failure for error management
This commit is contained in:
35
server/Cargo.lock
generated
35
server/Cargo.lock
generated
@@ -292,6 +292,26 @@ dependencies = [
|
|||||||
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "failure"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "failure_derive"
|
||||||
|
version = "0.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
@@ -905,6 +925,7 @@ version = "0.5.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"notify 4.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"notify 4.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@@ -1084,6 +1105,17 @@ dependencies = [
|
|||||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "synstructure"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2 0.4.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"quote 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempdir"
|
name = "tempdir"
|
||||||
version = "0.3.7"
|
version = "0.3.7"
|
||||||
@@ -1414,6 +1446,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
|
"checksum encoding_index_tests 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
|
||||||
"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38"
|
"checksum env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)" = "15b0a4d2e39f8420210be8b27eeda28029729e2fd4291019455016c348240c38"
|
||||||
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
|
"checksum error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff511d5dc435d703f4971bc399647c9bc38e20cb41452e3b9feb4765419ed3f3"
|
||||||
|
"checksum failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6dd377bcc1b1b7ce911967e3ec24fa19c3224394ec05b54aa7b083d498341ac7"
|
||||||
|
"checksum failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "64c2d913fe8ed3b6c6518eedf4538255b989945c14c2a7d5cbff62a5e2120596"
|
||||||
"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
|
"checksum filetime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a2df5c1a8c4be27e7707789dc42ae65976e60b394afd293d1419ab915833e646"
|
||||||
"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05"
|
"checksum fsevent 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "c4bbbf71584aeed076100b5665ac14e3d85eeb31fdbb45fbd41ef9a682b5ec05"
|
||||||
"checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874"
|
"checksum fsevent-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a772d36c338d07a032d5375a36f15f9a7043bf0cb8ce7cee658e037c6032874"
|
||||||
@@ -1504,6 +1538,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
"checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8"
|
||||||
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
|
||||||
"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7"
|
"checksum syn 0.15.22 (registry+https://github.com/rust-lang/crates.io-index)" = "ae8b29eb5210bc5cf63ed6149cbf9adfc82ac0be023d8735c176ee74a2db4da7"
|
||||||
|
"checksum synstructure 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "73687139bf99285483c96ac0add482c3776528beac1d97d444f6e91f203a2015"
|
||||||
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
|
||||||
"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2"
|
"checksum tempfile 3.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "7e91405c14320e5c79b3d148e1c86f40749a36e490642202a31689cb1a3452b2"
|
||||||
"checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561"
|
"checksum term 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e6b677dd1e8214ea1ef4297f85dbcbed8e8cdddb561040cc998ca2551c37561"
|
||||||
|
|||||||
@@ -30,10 +30,11 @@ rand = "0.4"
|
|||||||
regex = "1.0"
|
regex = "1.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
env_logger = "0.5"
|
env_logger = "0.5"
|
||||||
|
uuid = { version = "0.7", features = ["v4", "serde"] }
|
||||||
|
failure = "0.1.3"
|
||||||
rbx-tree = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
|
rbx-tree = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
|
||||||
rbxmx = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
|
rbxmx = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
|
||||||
rbxm = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
|
rbxm = { git = "https://github.com/LPGhatguy/rbx-tree.git" }
|
||||||
uuid = { version = "0.7", features = ["v4", "serde"] }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = "3.0"
|
tempfile = "3.0"
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ use std::{
|
|||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
fs::File,
|
fs::File,
|
||||||
io,
|
io,
|
||||||
fmt,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use failure::Fail;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
rbx_session::construct_oneoff_tree,
|
rbx_session::construct_oneoff_tree,
|
||||||
project::{Project, ProjectLoadFuzzyError},
|
project::{Project, ProjectLoadFuzzyError},
|
||||||
@@ -38,22 +39,16 @@ pub struct BuildOptions {
|
|||||||
pub output_kind: Option<OutputKind>,
|
pub output_kind: Option<OutputKind>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Fail)]
|
||||||
pub enum BuildError {
|
pub enum BuildError {
|
||||||
|
#[fail(display = "Could not detect what kind of file to create")]
|
||||||
UnknownOutputKind,
|
UnknownOutputKind,
|
||||||
ProjectLoadError(ProjectLoadFuzzyError),
|
|
||||||
IoError(io::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for BuildError {
|
#[fail(display = "Project load error: {}", _0)]
|
||||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
ProjectLoadError(#[fail(cause)] ProjectLoadFuzzyError),
|
||||||
match self {
|
|
||||||
BuildError::UnknownOutputKind => {
|
#[fail(display = "IO error: {}", _0)]
|
||||||
write!(output, "Could not detect what kind of output file to create")
|
IoError(#[fail(cause)] io::Error),
|
||||||
},
|
|
||||||
BuildError::ProjectLoadError(inner) => write!(output, "{}", inner),
|
|
||||||
BuildError::IoError(inner) => write!(output, "{}", inner),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ProjectLoadFuzzyError> for BuildError {
|
impl From<ProjectLoadFuzzyError> for BuildError {
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fmt,
|
|
||||||
fs,
|
fs,
|
||||||
io,
|
io,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use serde_json;
|
use failure::Fail;
|
||||||
use rbx_tree::RbxValue;
|
use rbx_tree::RbxValue;
|
||||||
|
|
||||||
pub static PROJECT_FILENAME: &'static str = "roblox-project.json";
|
pub static PROJECT_FILENAME: &'static str = "roblox-project.json";
|
||||||
|
|
||||||
// Serde is silly,
|
// Serde is silly.
|
||||||
const fn yeah() -> bool {
|
const fn yeah() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -89,35 +88,25 @@ impl SourceProject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum ProjectLoadExactError {
|
pub enum ProjectLoadExactError {
|
||||||
IoError(io::Error),
|
#[fail(display = "IO error: {}", _0)]
|
||||||
JsonError(serde_json::Error),
|
IoError(#[fail(cause)] io::Error),
|
||||||
|
|
||||||
|
#[fail(display = "JSON error: {}", _0)]
|
||||||
|
JsonError(#[fail(cause)] serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ProjectLoadExactError {
|
#[derive(Debug, Fail)]
|
||||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
match self {
|
|
||||||
ProjectLoadExactError::IoError(inner) => write!(output, "{}", inner),
|
|
||||||
ProjectLoadExactError::JsonError(inner) => write!(output, "{}", inner),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ProjectInitError {}
|
|
||||||
|
|
||||||
impl fmt::Display for ProjectInitError {
|
|
||||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(output, "ProjectInitError")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ProjectLoadFuzzyError {
|
pub enum ProjectLoadFuzzyError {
|
||||||
|
#[fail(display = "Project not found")]
|
||||||
NotFound,
|
NotFound,
|
||||||
IoError(io::Error),
|
|
||||||
JsonError(serde_json::Error),
|
#[fail(display = "IO error: {}", _0)]
|
||||||
|
IoError(#[fail(cause)] io::Error),
|
||||||
|
|
||||||
|
#[fail(display = "JSON error: {}", _0)]
|
||||||
|
JsonError(#[fail(cause)] serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ProjectLoadExactError> for ProjectLoadFuzzyError {
|
impl From<ProjectLoadExactError> for ProjectLoadFuzzyError {
|
||||||
@@ -129,24 +118,13 @@ impl From<ProjectLoadExactError> for ProjectLoadFuzzyError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ProjectLoadFuzzyError {
|
#[derive(Debug, Fail)]
|
||||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
#[fail(display = "Project init error")]
|
||||||
match self {
|
pub struct ProjectInitError;
|
||||||
ProjectLoadFuzzyError::NotFound => write!(output, "Project not found."),
|
|
||||||
ProjectLoadFuzzyError::IoError(inner) => write!(output, "{}", inner),
|
|
||||||
ProjectLoadFuzzyError::JsonError(inner) => write!(output, "{}", inner),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum ProjectSaveError {}
|
#[fail(display = "Project save error")]
|
||||||
|
pub struct ProjectSaveError;
|
||||||
impl fmt::Display for ProjectSaveError {
|
|
||||||
fn fmt(&self, output: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(output, "ProjectSaveError")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[serde(tag = "type")]
|
#[serde(tag = "type")]
|
||||||
|
|||||||
Reference in New Issue
Block a user