Skip to content

Commit

Permalink
stormlicht: handle failures in parsing file urls
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jul 26, 2024
1 parent de80a35 commit 46eee31
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions stormlicht/src/chrome/gtk/window/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ impl ObjectSubclass for Window {
None,
|win, _action_name, _action_target| async move {
match win.open_file_dialog().await {
Ok(file_path) => {
let url = URL::from(file_path.as_path());
win.imp().web_view.load(&url);
Ok(file_path) => match URL::try_from(file_path.as_path()) {
Ok(url) => {
win.imp().web_view.load(&url);
},
Err(e) => {
log::error!("Failed to parse path as url: {e:?}");
},
},
Err(error) => log::error!("Error loading file: {error}"),
}
Expand Down

0 comments on commit 46eee31

Please sign in to comment.