if upload image error send notify

This commit is contained in:
Medzik 2022-02-27 12:32:03 +01:00
parent 24d7be84fa
commit e129ab0d65
3 changed files with 10 additions and 3 deletions

View File

@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- added manpage
- added completion for elvish
### Library
- added Clone derive
## [0.3.0] - 2022-01-28
### CLI
- SimpleLogger init error handling

View File

@ -58,5 +58,3 @@ features = ["json", "rustls-tls"]
[dependencies.tokio]
version = "1.17.0"
features = ["macros", "rt-multi-thread"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -29,7 +29,13 @@ pub async fn upload_image(client: ImgurClient, path: &str) {
panic!("{path} is not a url")
}
let i = upload_img(client, &image).await.expect("send api request");
let i = upload_img(client, &image).await.unwrap_or_else(|err| {
notify!(Notification::new()
.summary("Error!")
.body(&format!("Error: {}", &err.to_string()))
.appname("Imgurs")); // I don't think you can set it to error
panic!("{}", err)
});
print_image_info(i.clone());
let body = format!("Uploaded {}", i.data.link);