feat(repl): Print errors and debug logs to stderr

Follow-up to 545007aca5.
This commit is contained in:
iequidoo
2025-06-21 13:10:36 -03:00
committed by iequidoo
parent 6d8dff54a7
commit c5c947e175
2 changed files with 8 additions and 8 deletions

View File

@@ -87,7 +87,7 @@ async fn poke_eml_file(context: &Context, filename: &Path) -> Result<()> {
let data = read_file(context, filename).await?; let data = read_file(context, filename).await?;
if let Err(err) = receive_imf(context, &data, false).await { if let Err(err) = receive_imf(context, &data, false).await {
println!("receive_imf errored: {err:?}"); eprintln!("receive_imf errored: {err:?}");
} }
Ok(()) Ok(())
} }
@@ -621,7 +621,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
println!("Location streaming enabled."); println!("Location streaming enabled.");
} }
println!("{cnt} chats"); println!("{cnt} chats");
println!("{time_needed:?} to create this list"); eprintln!("{time_needed:?} to create this list");
} }
"start-realtime" => { "start-realtime" => {
if arg1.is_empty() { if arg1.is_empty() {
@@ -731,7 +731,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
chat::marknoticed_chat(&context, sel_chat.get_id()).await?; chat::marknoticed_chat(&context, sel_chat.get_id()).await?;
let time_noticed_needed = time_noticed_start.elapsed().unwrap_or_default(); let time_noticed_needed = time_noticed_start.elapsed().unwrap_or_default();
println!( eprintln!(
"{time_needed:?} to create this list, {time_noticed_needed:?} to mark all messages as noticed." "{time_needed:?} to create this list, {time_noticed_needed:?} to mark all messages as noticed."
); );
} }
@@ -985,7 +985,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
}, },
query, query,
); );
println!("{time_needed:?} to create this list"); eprintln!("{time_needed:?} to create this list");
} }
"draft" => { "draft" => {
ensure!(sel_chat.is_some(), "No chat selected."); ensure!(sel_chat.is_some(), "No chat selected.");
@@ -1224,7 +1224,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
ensure!(!arg1.is_empty(), "Argument <qr-content> missing."); ensure!(!arg1.is_empty(), "Argument <qr-content> missing.");
match set_config_from_qr(&context, arg1).await { match set_config_from_qr(&context, arg1).await {
Ok(()) => println!("Config set from QR code, you can now call 'configure'"), Ok(()) => println!("Config set from QR code, you can now call 'configure'"),
Err(err) => println!("Cannot set config from QR code: {err:?}"), Err(err) => eprintln!("Cannot set config from QR code: {err:?}"),
} }
} }
"createqrsvg" => { "createqrsvg" => {

View File

@@ -311,7 +311,7 @@ impl Validator for DcHelper {}
async fn start(args: Vec<String>) -> Result<(), Error> { async fn start(args: Vec<String>) -> Result<(), Error> {
if args.len() < 2 { if args.len() < 2 {
println!("Error: Bad arguments, expected [db-name]."); eprintln!("Error: Bad arguments, expected [db-name].");
bail!("No db-name specified"); bail!("No db-name specified");
} }
let context = ContextBuilder::new(args[1].clone().into()) let context = ContextBuilder::new(args[1].clone().into())
@@ -366,7 +366,7 @@ async fn start(args: Vec<String>) -> Result<(), Error> {
false false
} }
Err(err) => { Err(err) => {
println!("Error: {err:#}"); eprintln!("Error: {err:#}");
true true
} }
} }
@@ -381,7 +381,7 @@ async fn start(args: Vec<String>) -> Result<(), Error> {
break; break;
} }
Err(err) => { Err(err) => {
println!("Error: {err:#}"); eprintln!("Error: {err:#}");
break; break;
} }
} }