From 9b3eb053b2adcf7123ecfb12a54fa24d2982d277 Mon Sep 17 00:00:00 2001 From: scoobybejesus Date: Tue, 27 Aug 2019 18:36:59 -0400 Subject: [PATCH] Error handling. Returned errors if CSV import failed. Resolves #14. --- src/core_functions.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/core_functions.rs b/src/core_functions.rs index ffe0c8c..4a6a6ae 100644 --- a/src/core_functions.rs +++ b/src/core_functions.rs @@ -70,7 +70,7 @@ pub fn import_and_process_final( println!("\nFailed to import accounts and transactions from CSV."); println!("{}", err); - return Err(err); + return Err(err) } }; @@ -90,7 +90,12 @@ pub fn import_and_process_final( match csv_import_accts_txns::import_accounts(&mut rdr, raw_acct_map, acct_map) { Ok(()) => {} - Err(err) => { println!("\nFailed to import accounts from CSV."); println!("{}", err); } + Err(err) => { + println!("\nFailed to import accounts from CSV."); + println!("{}", err); + + return Err(err) + } }; match csv_import_accts_txns::import_transactions( @@ -101,7 +106,12 @@ pub fn import_and_process_final( acct_map ) { Ok(()) => {} - Err(err) => { println!("\nFailed to import transactions from CSV."); println!("{}", err); } + Err(err) => { + println!("\nFailed to import transactions from CSV."); + println!("{}", err); + + return Err(err) + } }; Ok(()) @@ -136,7 +146,7 @@ pub fn import_and_process_final( println!(" Successfully created lots and movements."); - import_cost_proceeds_etc::add_cost_basis_to_movements( + import_cost_proceeds_etc::add_cost_basis_to_movements( &settings, &action_records_map, &raw_account_map,