From 231da572e531f036d815732ca849b259f3ace535 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 26 Nov 2024 02:44:54 +0100 Subject: [PATCH] Renamed error listener to onError --- .../kotlin/net/codinux/invoicing/mail/EmailsFetcher.kt | 6 +++--- .../net/codinux/invoicing/mail/FetchEmailsStatus.kt | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/EmailsFetcher.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/EmailsFetcher.kt index c6f52ea..873fc53 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/EmailsFetcher.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/EmailsFetcher.kt @@ -35,13 +35,13 @@ open class EmailsFetcher( open fun listenForNewEmails(account: EmailAccount, downloadMessageBody: Boolean = false, emailFolderName: String = "INBOX", - error: ((FetchEmailsError) -> Unit)? = null, emailReceived: (EmailWithInvoice) -> Unit) = runBlocking { + onError: ((FetchEmailsError) -> Unit)? = null, emailReceived: (EmailWithInvoice) -> Unit) = runBlocking { try { connect(account) { store -> val folder = store.getFolder(emailFolderName) folder.open(Folder.READ_ONLY) - val status = FetchEmailsStatus(FetchEmailsOptions(downloadMessageBody)) + val status = FetchEmailsStatus(FetchEmailsOptions(downloadMessageBody), onError = onError) folder.addMessageCountListener(object : MessageCountAdapter() { override fun messagesAdded(event: MessageCountEvent) { @@ -59,7 +59,7 @@ open class EmailsFetcher( } } catch (e: Throwable) { log.error(e) { "Listening to new emails of '${account.username}' failed" } - error?.invoke(FetchEmailsError(FetchEmailsErrorType.ListenForNewEmails, null, e)) + onError?.invoke(FetchEmailsError(FetchEmailsErrorType.ListenForNewEmails, null, e)) } log.info { "Stopped listening to new emails of '${account.username}'" } diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/FetchEmailsStatus.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/FetchEmailsStatus.kt index f8e46d6..a1a0abd 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/FetchEmailsStatus.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/mail/FetchEmailsStatus.kt @@ -7,7 +7,7 @@ import jakarta.mail.Part data class FetchEmailsStatus( val options: FetchEmailsOptions, val messageSpecificErrors: MutableList = mutableListOf(), - val error: ((FetchEmailsError) -> Unit)? = null + val onError: ((FetchEmailsError) -> Unit)? = null ) { fun addError(type: FetchEmailsErrorType, parts: Collection, error: Throwable) = @@ -19,10 +19,10 @@ data class FetchEmailsStatus( fun addError(type: FetchEmailsErrorType, messageNumber: Int?, error: Throwable) = addError(FetchEmailsError(type, messageNumber, error)) - fun addError(mailError: FetchEmailsError) { - messageSpecificErrors.add(mailError) + fun addError(error: FetchEmailsError) { + messageSpecificErrors.add(error) - error?.invoke(mailError) + onError?.invoke(error) } private fun getMessage(part: Part): Message? {