Skip to content

Commit a8f8d34

Browse files
authored
feat: understandable error message when accounts.lock can't be locked (#6695)
Targets #6636 Right now the error message is: > Error: Delta Chat is already running. To use Delta Chat, you must first close the existing Delta Chat process, or restart your device. > > (accounts.lock lock file is already locked) other suggestions welcome!
1 parent a308766 commit a8f8d34

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

deltachat-rpc-server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async fn main() {
3030
// thread, and it is impossible to cancel that read. This can make shutdown of the runtime hang
3131
// until the user presses enter."
3232
if let Err(error) = &r {
33-
log::error!("Fatal error: {error:#}.")
33+
log::error!("Error: {error:#}.")
3434
}
3535
std::process::exit(if r.is_ok() { 0 } else { 1 });
3636
}

src/accounts.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::BTreeMap;
44
use std::future::Future;
55
use std::path::{Path, PathBuf};
66

7-
use anyhow::{ensure, Context as _, Result};
7+
use anyhow::{bail, ensure, Context as _, Result};
88
use futures::stream::FuturesUnordered;
99
use futures::StreamExt;
1010
use serde::{Deserialize, Serialize};
@@ -73,9 +73,7 @@ impl Accounts {
7373
let config_file = dir.join(CONFIG_NAME);
7474
ensure!(config_file.exists(), "{:?} does not exist", config_file);
7575

76-
let config = Config::from_file(config_file, writable)
77-
.await
78-
.context("failed to load accounts config")?;
76+
let config = Config::from_file(config_file, writable).await?;
7977
let events = Events::new();
8078
let stockstrings = StockStrings::new();
8179
let push_subscriber = PushSubscriber::new();
@@ -460,7 +458,9 @@ impl Config {
460458
rx.await?;
461459
Ok(())
462460
});
463-
locked_rx.await?;
461+
if locked_rx.await.is_err() {
462+
bail!("Delta Chat is already running. To use Delta Chat, you must first close the existing Delta Chat process, or restart your device. (accounts.lock file is already locked)");
463+
};
464464
Ok(Some(lock_task))
465465
}
466466

0 commit comments

Comments
 (0)