Skip to content

Commit

Permalink
Include url in all Browse error conditions
Browse files Browse the repository at this point in the history
This makes it safer to use fwd-browse as your BROWSER. Even if you haven't
started a fwd session at least you'll get the url the program you were using
wanted to open.
  • Loading branch information
quodlibetor committed Nov 3, 2023
1 parent fd02779 commit 17a8a34
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/browse/browse_unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ use users;
use xdg;

pub async fn browse_url_impl(url: &String) -> Result<()> {
let path = socket_path().context("Error getting socket path")?;
let path = socket_path().context(format!(
"fwd-browse: Error getting socket path. \n\
Start a fwd session to open: {url}"
))?;
let stream = UnixStream::connect(&path).await.context(
"Error connecting to socket (is fwd actually connected here?)",
format!(
"fwd-browse: Error connecting to socket (is fwd actually connected here?) \n\
Start a fwd session to open: {url}"),
)?;
let mut writer = MessageWriter::new(stream);
writer
.write(Message::Browse(url.clone()))
.await
.context("Error sending browse message")?;
.context(format!(
"Error sending browse message \n\
Start a fwd session to open: {url}"
))?;
Ok(())
}

Expand Down

0 comments on commit 17a8a34

Please sign in to comment.