Skip to content

Commit fa7dddd

Browse files
authored
gpui: Don't panic when failing to exec system opener (#21674)
1 parent 4d22a07 commit fa7dddd

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

crates/gpui/src/platform/linux/platform.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::{
1818
time::Duration,
1919
};
2020

21-
use anyhow::anyhow;
21+
use anyhow::{anyhow, Context as _};
2222
use async_task::Runnable;
2323
use calloop::channel::Channel;
2424
use calloop::{EventLoop, LoopHandle, LoopSignal};
@@ -382,14 +382,14 @@ impl<P: LinuxClient + 'static> Platform for P {
382382
}
383383

384384
fn open_with_system(&self, path: &Path) {
385-
let executor = self.background_executor().clone();
386385
let path = path.to_owned();
387-
executor
386+
self.background_executor()
388387
.spawn(async move {
389388
let _ = std::process::Command::new("xdg-open")
390389
.arg(path)
391390
.spawn()
392-
.expect("Failed to open file with xdg-open");
391+
.context("invoking xdg-open")
392+
.log_err();
393393
})
394394
.detach();
395395
}

crates/gpui/src/platform/mac/platform.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
PlatformTextSystem, PlatformWindow, Result, ScreenCaptureSource, SemanticVersion, Task,
1111
WindowAppearance, WindowParams,
1212
};
13-
use anyhow::anyhow;
13+
use anyhow::{anyhow, Context as _};
1414
use block::ConcreteBlock;
1515
use cocoa::{
1616
appkit::{
@@ -57,6 +57,7 @@ use std::{
5757
sync::Arc,
5858
};
5959
use strum::IntoEnumIterator;
60+
use util::ResultExt;
6061

6162
#[allow(non_upper_case_globals)]
6263
const NSUTF8StringEncoding: NSUInteger = 4;
@@ -779,15 +780,16 @@ impl Platform for MacPlatform {
779780
}
780781

781782
fn open_with_system(&self, path: &Path) {
782-
let path = path.to_path_buf();
783+
let path = path.to_owned();
783784
self.0
784785
.lock()
785786
.background_executor
786787
.spawn(async move {
787-
std::process::Command::new("open")
788+
let _ = std::process::Command::new("open")
788789
.arg(path)
789790
.spawn()
790-
.expect("Failed to open file");
791+
.context("invoking open command")
792+
.log_err();
791793
})
792794
.detach();
793795
}

0 commit comments

Comments
 (0)