Skip to content

Commit

Permalink
add error dialog box when GUI is started
Browse files Browse the repository at this point in the history
  • Loading branch information
TabulateJarl8 committed Feb 24, 2022
1 parent 6d54645 commit 3f69c8f
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 14 deletions.
117 changes: 109 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[package]
name = "wordle_finder"
version = "2.2.3"
version = "2.2.4"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "3.0.14"
native-dialog = { version = "0.6.3", features = ["windows_dpi_awareness", "windows_visual_styles"] }
regex = "1.5.4"
serde = { version = "1.0.136", features = ["derive"] }
serde_json = "1.0.79"
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ Rust program to help find the wordle word
## Use
This program can be used from a terminal, run `./wordle_finder --help` for more info. If you'd like to use the GUI frontend, you can launch it by running `./wordle_finder -g` in a terminal or opening the binary from a file explorer.

<details>
<summary>GUI Frontend for version 2.0.0</summary>
<img src="https://user-images.githubusercontent.com/58576759/154787824-4358b931-f161-4ecb-9859-ba21066512c2.png" alt="GUI" />
</details>
![GUI Example](assets/main_ui.png)

## Downloading
I provide pre-built binaries on the releases page. I do not test the Windows binary, but it may work.
Expand Down
Binary file added img/main_ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use clap::{Arg, Command};
use regex::Regex;
use native_dialog::{MessageDialog, MessageType};

mod gui;
mod utils;
Expand Down Expand Up @@ -60,7 +61,22 @@ fn main() {
// this should launch the GUI if run from a file explorer
if matches.is_present("gui") || std::env::args().len() == 1 {
match gui::run_gui() {
Err(error) => panic!("Error when running GUI: {:?}", error),
Err(error) => {
let result = MessageDialog::new()
.set_title("Error")
.set_text(&format!("{:?}", &error))
.set_type(MessageType::Error)
.show_alert();

match result {
Err(second_error) => {
eprintln!("Error when launching MessageDialog: {}", second_error);
panic!("Error when running GUI: {:?}", error);
},
_ => ()
}

},
_ => (),
};
std::process::exit(0);
Expand Down

0 comments on commit 3f69c8f

Please sign in to comment.