Skip to content

Commit d0e69f7

Browse files
l-constmmstick
authored andcommitted
fix: Check for cancellation and not panic and notify for the crash.
1 parent f08430e commit d0e69f7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/main.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,19 @@ async fn main() {
7272
.send()
7373
.await
7474
.expect("failed to send screenshot request")
75-
.response()
76-
.expect("failed to receive screenshot response");
75+
.response();
76+
77+
let response = match response {
78+
Err(err) => {
79+
if err.to_string().contains("Cancelled") {
80+
println!("Screenshot cancelled by user");
81+
std::process::exit(0);
82+
}
83+
eprintln!("Error taking screenshot: {}", err);
84+
std::process::exit(1);
85+
}
86+
Ok(response) => response,
87+
};
7788

7889
let uri = response.uri();
7990
let path = match uri.scheme() {

0 commit comments

Comments
 (0)