Skip to content

Commit

Permalink
#2 moving error handling to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
hlafaille committed Mar 13, 2024
1 parent ae66a78 commit c2e1693
Showing 1 changed file with 33 additions and 8 deletions.
41 changes: 33 additions & 8 deletions src/frontend/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ pub fn run(

// run it
print_general("Running 'artifact.jar'");
run_jar(&p_ctx, &tc_ctx);
match run_jar(&p_ctx, &tc_ctx) {
Ok(_) => (),
Err(e) => {
print_err(format!("Failed to run 'artifact.jar': {}", {e}).as_str())
}
}
Ok(())
}

Expand All @@ -50,7 +55,7 @@ pub fn build(
override_tc_ctx: Option<ToolchainContext>,
) -> result::Result<(ProjectContext, ToolchainContext), Box<dyn error::Error>> {
// handle an override project context
let mut p_ctx: ProjectContext;
let p_ctx: ProjectContext;
match override_p_ctx {
Some(v) => p_ctx = v,
None => p_ctx = get_project_context()?,
Expand Down Expand Up @@ -84,7 +89,12 @@ pub fn build(

// build our jar
print_general("Packaging");
backend::toolchain::build_jar(&p_ctx, &tc_ctx);
match backend::toolchain::build_jar(&p_ctx, &tc_ctx) {
Ok(_) => (),
Err(e) => {
print_err(format!("Failed to package 'artifact.jar': {}", {e}).as_str());
}
}

print_general(" ^~~^ ...done!");

Expand All @@ -98,7 +108,7 @@ pub fn build(
pub fn init() {
// get absolute paths
let ap: AbsoltuePaths = match context::get_absolute_paths(&context::get_debug_mode()) {
Err(e) => {
Err(_) => {
print_general("Failed to get absolute paths");
return;
}
Expand Down Expand Up @@ -129,21 +139,36 @@ pub fn init() {
}

// ensure our environment is setup
backend::project::ensure_environment(&ap, &backend::context::get_debug_mode());
match backend::project::ensure_environment(&ap, &backend::context::get_debug_mode()) {
Ok(_) => (),
Err(e) => {
print_err(format!("Failed to ensure environment: {}", {e}).as_str());
}
}

// initialize the config
backend::project::initialize_config(name, base_package, &ap);
match backend::project::initialize_config(name, base_package, &ap) {
Ok(_) => (),
Err(e) => {
print_err(format!("Failed to run initialize config: {}", {e}).as_str());
}
}

// get our project context
let p_ctx = match backend::context::get_project_context() {
Err(e) => {
Err(_) => {
print_general("Failed to get project context");
return;
}
Ok(x) => x,
};

// initialize our source tree
backend::project::initialize_source_tree(&p_ctx);
match backend::project::initialize_source_tree(&p_ctx) {
Ok(_) => (),
Err(e) => {
print_err(format!("Failed to run 'artifact.jar': {}", {e}).as_str());
}
}
print_general("Project created: Edit espresso.toml to check it out!");
}

0 comments on commit c2e1693

Please sign in to comment.