Merge pull request #7627 from thunderbird/more_error_logging
Add more debug logging when checking server settings
This commit is contained in:
commit
b893883d13
4 changed files with 18 additions and 14 deletions
|
@ -212,15 +212,17 @@ internal open class RealImapStore(
|
|||
return folderName.substring(prefixLength)
|
||||
}
|
||||
|
||||
@Throws(MessagingException::class)
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
@Throws(MessagingException::class, IOException::class)
|
||||
override fun checkSettings() {
|
||||
try {
|
||||
val connection = createImapConnection()
|
||||
|
||||
connection.open()
|
||||
connection.close()
|
||||
} catch (e: IOException) {
|
||||
throw MessagingException("Unable to connect", e)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Error while checking server settings")
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
package com.fsck.k9.mail.store.imap
|
||||
|
||||
import assertk.all
|
||||
import assertk.assertFailure
|
||||
import assertk.assertThat
|
||||
import assertk.assertions.cause
|
||||
import assertk.assertions.containsExactly
|
||||
import assertk.assertions.hasMessage
|
||||
import assertk.assertions.isInstanceOf
|
||||
import assertk.assertions.isNotNull
|
||||
import assertk.assertions.isSameInstanceAs
|
||||
|
@ -44,18 +41,16 @@ class RealImapStoreTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `checkSettings() with open throwing should throw MessagingException`() {
|
||||
fun `checkSettings() with open throwing an IOException should pass it through`() {
|
||||
val ioException = IOException()
|
||||
val imapConnection = createMockConnection().stub {
|
||||
on { open() } doThrow IOException::class
|
||||
on { open() } doThrow ioException
|
||||
}
|
||||
imapStore.enqueueImapConnection(imapConnection)
|
||||
|
||||
assertFailure {
|
||||
imapStore.checkSettings()
|
||||
}.isInstanceOf<MessagingException>().all {
|
||||
hasMessage("Unable to connect")
|
||||
cause().isNotNull().isInstanceOf<IOException>()
|
||||
}
|
||||
}.isSameInstanceAs(ioException)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -4,6 +4,7 @@ package com.fsck.k9.mail.store.pop3;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fsck.k9.logging.Timber;
|
||||
import com.fsck.k9.mail.AuthType;
|
||||
import com.fsck.k9.mail.ConnectionSecurity;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
|
@ -54,8 +55,10 @@ public class Pop3Store {
|
|||
try {
|
||||
folder.open();
|
||||
folder.requestUidl();
|
||||
}
|
||||
finally {
|
||||
} catch (Exception e) {
|
||||
Timber.e(e, "Error while checking server settings");
|
||||
throw e;
|
||||
} finally {
|
||||
folder.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -665,12 +665,16 @@ class SmtpTransport(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("TooGenericExceptionCaught")
|
||||
@Throws(MessagingException::class)
|
||||
fun checkSettings() {
|
||||
ensureClosed()
|
||||
|
||||
try {
|
||||
open()
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Error while checking server settings")
|
||||
throw e
|
||||
} finally {
|
||||
close()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue