Improve error messages for 'serve' command.

Rojo now throws an error if no project file could be found.

Fixes #63.
This commit is contained in:
Lucien Greathouse
2018-04-20 21:45:48 -07:00
parent 29a83cb626
commit 8c482f75dd
2 changed files with 10 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
# Rojo Change Log
## Current Master
*No changes*
* Rojo now throws an error if no project file is found. ([#63](https://github.com/LPGhatguy/rojo/issues/63))
## 0.4.4 (April 7, 2018)
* Fix small regression introduced in 0.4.3

View File

@@ -14,10 +14,6 @@ use web;
pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
let server_id = rand::random::<u64>();
if verbose {
println!("Attempting to locate project at {}...", project_path.display());
}
let project = match Project::load(project_path) {
Ok(v) => {
println!("Using project from {}", project_path.display());
@@ -26,27 +22,23 @@ pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
Err(err) => {
match err {
ProjectLoadError::InvalidJson(serde_err) => {
eprintln!(
"Found invalid JSON!\nProject in: {}\nError: {}",
project_path.display(),
serde_err,
);
eprintln!("Project contained invalid JSON!");
eprintln!("{}", project_path.display());
eprintln!("Error: {}", serde_err);
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(),
);
eprintln!("Check the permissions of the project file at {}", project_path.display());
process::exit(1);
},
_ => {
// Any other error is fine; use the default project.
println!("Found no project file, using default project...");
Project::default()
ProjectLoadError::DidNotExist => {
eprintln!("Found no project file! Create one using 'rojo init'");
eprintln!("Checked for a project at {}", project_path.display());
process::exit(1);
},
}
},