made all errors verbose

This commit is contained in:
Alie 2023-07-14 11:03:28 +02:00
parent c0b134b9a0
commit 87ca81c18a
2 changed files with 16 additions and 6 deletions

10
run_with_log.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
mastodon-image-uploader-bot >./tmp/log.out 2>./tmp/log.err
if [ ! -s ./tmp/log.err ]; then
echo -n "$(date +"[%Y-%M-%d %T]") success: " >> ./bot.log
cat ./tmp/log.out >> ./bot.log
else
echo -n "$(date +"[%Y-%M-%d %T]") errors: " >> ./bot.log
cat ./tmp/log.err >> ./bot.log
fi

View File

@ -78,8 +78,8 @@ fn get_next_url(config: &Config) -> Option<String> {
.write(true) .write(true)
.append(true) // This is needed to append to file .append(true) // This is needed to append to file
.open(&config.files.posted) .open(&config.files.posted)
.unwrap(); .expect("Cannot open posted file"); // Maybe we should retry just in case
write!(file, "{}\n", urls[0]).unwrap(); write!(file, "{}\n", urls[0]).expect("Cannot write to posted file"); // maybe we should retry tbh
Some(urls[0].to_string().clone()) Some(urls[0].to_string().clone())
} }
} }
@ -101,8 +101,8 @@ async fn post_image(account: &Mastodon, url: &String, config: &Config) {
.visibility(Visibility::Unlisted) .visibility(Visibility::Unlisted)
.sensitive(true) .sensitive(true)
.build() .build()
.unwrap(); .expect("Could not build status"); // we should retry
account.new_status(status).await.expect("Error generating status"); account.new_status(status).await.expect("Error generating status"); // we should retry or delete last url in posted
println!("Status posted") println!("Status posted")
} }
@ -127,9 +127,9 @@ async fn update_bio(account: &Mastodon, config: &Config) {
), ),
]) ])
.spawn() .spawn()
.unwrap() .expect("Could not spawn curl")
.wait() .wait()
.unwrap(); .expect("Curl failed");
} }
async fn post(account: &Mastodon, msg: &str) { async fn post(account: &Mastodon, msg: &str) {