diff --git a/CHANGELOG.md b/CHANGELOG.md index 700e500e0..9a9b3bd8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - set a default error if NDN does not provide an error - python: avoid exceptions when messages/contacts/chats are compared with `None` - node: wait for the event loop to stop before destroying contexts #3431 +- emit configuration errors via event on failure #3433 ### API-Changes - python: added `Message.get_status_updates()` #3416 diff --git a/node/test/test.js b/node/test/test.js index ce41ef6f3..c5f4fa735 100644 --- a/node/test/test.js +++ b/node/test/test.js @@ -128,7 +128,7 @@ describe('Basic offline Tests', function () { await expect( context.configure({ addr: 'delta1@delta.localhost' }) - ).to.eventually.be.rejectedWith('Please enter a password.') + ).to.eventually.be.rejectedWith('Missing (IMAP) password.') await expect(context.configure({ mailPw: 'delta1' })).to.eventually.be .rejected diff --git a/src/configure.rs b/src/configure.rs index bf4028a61..80136af1a 100644 --- a/src/configure.rs +++ b/src/configure.rs @@ -75,6 +75,24 @@ impl Context { })) .await; + if let Err(err) = res.as_ref() { + progress!( + self, + 0, + Some( + stock_str::configuration_failed( + self, + // We are using Anyhow's .context() and to show the + // inner error, too, we need the {:#}: + format!("{:#}", err), + ) + .await + ) + ); + } else { + progress!(self, 1000); + } + self.free_ongoing().await; res @@ -114,30 +132,10 @@ impl Context { } } - match success { - Ok(_) => { - self.set_config(Config::NotifyAboutWrongPw, Some("1")) - .await?; - progress!(self, 1000); - Ok(()) - } - Err(err) => { - progress!( - self, - 0, - Some( - stock_str::configuration_failed( - self, - // We are using Anyhow's .context() and to show the - // inner error, too, we need the {:#}: - format!("{:#}", err), - ) - .await - ) - ); - Err(err) - } - } + success?; + self.set_config(Config::NotifyAboutWrongPw, Some("1")) + .await?; + Ok(()) } }