forked from rojo-rbx/rojo
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:
@@ -1,7 +1,7 @@
|
|||||||
# Rojo Change Log
|
# Rojo Change Log
|
||||||
|
|
||||||
## Current Master
|
## 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)
|
## 0.4.4 (April 7, 2018)
|
||||||
* Fix small regression introduced in 0.4.3
|
* Fix small regression introduced in 0.4.3
|
||||||
|
|||||||
@@ -14,10 +14,6 @@ use web;
|
|||||||
pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
|
pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
|
||||||
let server_id = rand::random::<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) {
|
let project = match Project::load(project_path) {
|
||||||
Ok(v) => {
|
Ok(v) => {
|
||||||
println!("Using project from {}", project_path.display());
|
println!("Using project from {}", project_path.display());
|
||||||
@@ -26,27 +22,23 @@ pub fn serve(project_path: &PathBuf, verbose: bool, port: Option<u64>) {
|
|||||||
Err(err) => {
|
Err(err) => {
|
||||||
match err {
|
match err {
|
||||||
ProjectLoadError::InvalidJson(serde_err) => {
|
ProjectLoadError::InvalidJson(serde_err) => {
|
||||||
eprintln!(
|
eprintln!("Project contained invalid JSON!");
|
||||||
"Found invalid JSON!\nProject in: {}\nError: {}",
|
eprintln!("{}", project_path.display());
|
||||||
project_path.display(),
|
eprintln!("Error: {}", serde_err);
|
||||||
serde_err,
|
|
||||||
);
|
|
||||||
|
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
},
|
},
|
||||||
ProjectLoadError::FailedToOpen | ProjectLoadError::FailedToRead => {
|
ProjectLoadError::FailedToOpen | ProjectLoadError::FailedToRead => {
|
||||||
eprintln!("Found project file, but failed to read it!");
|
eprintln!("Found project file, but failed to read it!");
|
||||||
eprintln!(
|
eprintln!("Check the permissions of the project file at {}", project_path.display());
|
||||||
"Check the permissions of the project file at\n{}",
|
|
||||||
project_path.display(),
|
|
||||||
);
|
|
||||||
|
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
},
|
},
|
||||||
_ => {
|
ProjectLoadError::DidNotExist => {
|
||||||
// Any other error is fine; use the default project.
|
eprintln!("Found no project file! Create one using 'rojo init'");
|
||||||
println!("Found no project file, using default project...");
|
eprintln!("Checked for a project at {}", project_path.display());
|
||||||
Project::default()
|
|
||||||
|
process::exit(1);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user