mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-25 15:16:07 +00:00
Add more detailed error reporting around invalid projects
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
# Rojo Change Log
|
# Rojo Change Log
|
||||||
|
|
||||||
## Current Master
|
## Current Master
|
||||||
* *No changes*
|
* Improved error reporting when invalid JSON is found in a `rojo.json` project
|
||||||
|
* These messages are passed on from Serde
|
||||||
|
|
||||||
## 0.3.0
|
## 0.3.0
|
||||||
* Factored out the plugin into a separate repository
|
* Factored out the plugin into a separate repository
|
||||||
|
|||||||
30
src/bin.rs
30
src/bin.rs
@@ -25,7 +25,7 @@ use std::thread;
|
|||||||
|
|
||||||
use core::Config;
|
use core::Config;
|
||||||
use pathext::canonicalish;
|
use pathext::canonicalish;
|
||||||
use project::Project;
|
use project::{Project, ProjectLoadError};
|
||||||
use vfs::Vfs;
|
use vfs::Vfs;
|
||||||
use vfs_watch::VfsWatcher;
|
use vfs_watch::VfsWatcher;
|
||||||
|
|
||||||
@@ -98,8 +98,32 @@ fn main() {
|
|||||||
println!("Using project from {}", project_path.display());
|
println!("Using project from {}", project_path.display());
|
||||||
v
|
v
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(err) => {
|
||||||
println!("Using default project...");
|
match err {
|
||||||
|
ProjectLoadError::InvalidJson(serde_err) => {
|
||||||
|
eprintln!(
|
||||||
|
"Found invalid JSON!\nProject in: {}\nError: {}",
|
||||||
|
project_path.display(),
|
||||||
|
serde_err,
|
||||||
|
);
|
||||||
|
|
||||||
|
std::process::exit(1);
|
||||||
|
},
|
||||||
|
ProjectLoadError::FailedToOpen | ProjectLoadError::FailedToRead => {
|
||||||
|
eprintln!("Found project file, but failed to read it!");
|
||||||
|
eprintln!(
|
||||||
|
"Check the permissions of the project file at\n{}",
|
||||||
|
project_path.display(),
|
||||||
|
);
|
||||||
|
|
||||||
|
std::process::exit(1);
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
// Any other error is fine; use the default project.
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Found no project file, using default project...");
|
||||||
Project::default()
|
Project::default()
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ pub enum ProjectLoadError {
|
|||||||
DidNotExist,
|
DidNotExist,
|
||||||
FailedToOpen,
|
FailedToOpen,
|
||||||
FailedToRead,
|
FailedToRead,
|
||||||
Invalid,
|
InvalidJson(serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@@ -116,7 +116,7 @@ impl Project {
|
|||||||
|
|
||||||
match serde_json::from_str(&contents) {
|
match serde_json::from_str(&contents) {
|
||||||
Ok(v) => Ok(v),
|
Ok(v) => Ok(v),
|
||||||
Err(_) => return Err(ProjectLoadError::Invalid),
|
Err(e) => return Err(ProjectLoadError::InvalidJson(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user