From 7b02452ef57026c5020bd9fc4a99ec4c4ad19361 Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Tue, 4 Jul 2023 18:43:19 -0400 Subject: [PATCH 1/2] improves panic message. --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 139394c..db46799 100644 --- a/src/main.rs +++ b/src/main.rs @@ -120,7 +120,10 @@ fn manage_directory_entry( item: &serde_json::value::Value ) { // debug!( "{}", format!("item from within manage_directory_entry, ``{:?}``", item) ); // yields (EG): item, ``Object({"path": String("/foo/the.log")})`` // -- get path String from json-dict-object - let path_rfrnc = item["path"].as_str().unwrap_or_else( || {panic!("problem reading path from json-obj -- ``{:?}``");} ); + let path_value = &item["path"]; + let path_rfrnc = path_value.as_str().unwrap_or_else(|| { + panic!("problem reading path from json-obj: {:?}", path_value); + }); // let zz: () = path_rfrnc; // yields: found `&str` let path: String = path_rfrnc.into(); // let zz: () = path; // yields: found struct `std::string::String` From 95d17a2df59430cfafc28eca23c8db637f4ecbca Mon Sep 17 00:00:00 2001 From: Birkin James Diana Date: Tue, 4 Jul 2023 18:46:29 -0400 Subject: [PATCH 2/2] updates panic messages. --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index db46799..cc56964 100644 --- a/src/main.rs +++ b/src/main.rs @@ -213,7 +213,8 @@ fn process_file( file_path: &str, file_name: &str, parent_path: &str ) { _ => { let err_message = "unexpected extension found".to_string(); error!( "{}", err_message ); - panic!( err_message ); + // panic!( err_message ); + panic!( "{}", err_message ); } }; debug!( "{}", format!("new_extension, ``{:?}``", new_extension) ); @@ -227,7 +228,8 @@ fn process_file( file_path: &str, file_name: &str, parent_path: &str ) { let bytes_copied = fs::copy( file_path, destination_path ).unwrap_or_else( |err| { let err_message = format!( "problem copying the file, ``{}``", err ); error!( "{}", err_message ); - panic!( err_message ); + // panic!( err_message ); + panic!( "{}", err_message ); }); info!( "{}", format!("copied ``{:?}K``", (bytes_copied / 1024)) ); @@ -237,7 +239,8 @@ fn process_file( file_path: &str, file_name: &str, parent_path: &str ) { let _empty_file = File::create(&path).unwrap_or_else( |err| { let err_message = format!( "problem creating new empty file, ``{}``", err ); error!( "{}", err_message ); - panic!( err_message ); + // panic!( err_message ); + panic!( "{}", err_message ); }); }