diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt index 5c526b7..b9b8cde 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/EmailsFetcher.kt @@ -62,7 +62,7 @@ open class EmailsFetcher( } } catch (e: Throwable) { log.error(e) { "Listening to new emails of '${account.username}' failed" } - options.onError?.invoke(FetchEmailsError(FetchEmailsErrorType.ListenForNewEmails, null, e)) + options.onError?.invoke(FetchEmailError(FetchEmailErrorType.ListenForNewEmails, null, e)) } } @@ -206,7 +206,7 @@ open class EmailsFetcher( } } catch (e: Throwable) { log.error(e) { "Could not check attachment '${messagePart.part.fileName}' (${messagePart.mediaType}) for eInvoice" } - status.addError(FetchEmailsErrorType.GetAttachment, messagePart.part, e) + status.addError(FetchEmailErrorType.GetAttachment, messagePart.part, e) } return null @@ -307,7 +307,7 @@ open class EmailsFetcher( } } catch (e: Throwable) { log.error(e) { "Could not get message body for media type '$mediaType'" } - status.addError(FetchEmailsErrorType.GetMesssageBody, parts.map { it.part }, e) + status.addError(FetchEmailErrorType.GetMesssageBody, parts.map { it.part }, e) null } diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsError.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailError.kt similarity index 57% rename from e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsError.kt rename to e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailError.kt index d37ebc7..02287f1 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsError.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailError.kt @@ -1,7 +1,7 @@ package net.codinux.invoicing.email -data class FetchEmailsError( - val type: FetchEmailsErrorType, +data class FetchEmailError( + val type: FetchEmailErrorType, val messageNumber: Int?, val error: Throwable ) \ No newline at end of file diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsErrorType.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailErrorType.kt similarity index 79% rename from e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsErrorType.kt rename to e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailErrorType.kt index 16b3c56..70a69d6 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsErrorType.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailErrorType.kt @@ -1,6 +1,6 @@ package net.codinux.invoicing.email -enum class FetchEmailsErrorType { +enum class FetchEmailErrorType { GetEmail, GetMesssageBody, diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt index cabaecc..d135ff3 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsOptions.kt @@ -25,7 +25,7 @@ open class FetchEmailsOptions( val emailFolderName: String = "INBOX", val connectTimeoutSeconds: Int = 5, - val onError: ((FetchEmailsError) -> Unit)? = null, + val onError: ((FetchEmailError) -> Unit)? = null, val onEmailReceived: ((Email) -> Unit)? = null ) { companion object { diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsResult.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsResult.kt index 86360e7..f4107a6 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsResult.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsResult.kt @@ -5,5 +5,5 @@ import net.codinux.invoicing.email.model.Email data class FetchEmailsResult( val emails: List, val overallError: Throwable?, - val messageSpecificErrors: List = emptyList() + val messageSpecificErrors: List = emptyList() ) \ No newline at end of file diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsStatus.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsStatus.kt index 67f81e3..35ead31 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsStatus.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/FetchEmailsStatus.kt @@ -12,7 +12,7 @@ data class FetchEmailsStatus( val account: EmailAccount, val folder: IMAPFolder, val options: FetchEmailsOptions, - val messageSpecificErrors: MutableList = mutableListOf() + val messageSpecificErrors: MutableList = mutableListOf() ) { val userAttachmentsDownloadDirectory: File by lazy { @@ -22,16 +22,16 @@ data class FetchEmailsStatus( } - fun addError(type: FetchEmailsErrorType, parts: Collection, error: Throwable) = - addError(FetchEmailsError(type, parts.firstNotNullOfOrNull { getMessage(it) }?.messageNumber, error)) + fun addError(type: FetchEmailErrorType, parts: Collection, error: Throwable) = + addError(FetchEmailError(type, parts.firstNotNullOfOrNull { getMessage(it) }?.messageNumber, error)) - fun addError(type: FetchEmailsErrorType, part: Part, error: Throwable) = - addError(FetchEmailsError(type, getMessage(part)?.messageNumber, error)) + fun addError(type: FetchEmailErrorType, part: Part, error: Throwable) = + addError(FetchEmailError(type, getMessage(part)?.messageNumber, error)) - fun addError(type: FetchEmailsErrorType, messageNumber: Int?, error: Throwable) = - addError(FetchEmailsError(type, messageNumber, error)) + fun addError(type: FetchEmailErrorType, messageNumber: Int?, error: Throwable) = + addError(FetchEmailError(type, messageNumber, error)) - fun addError(error: FetchEmailsError) { + fun addError(error: FetchEmailError) { messageSpecificErrors.add(error) options.onError?.invoke(error) diff --git a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt index 6ba31f5..9764e48 100644 --- a/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt +++ b/e-invoice-domain/src/main/kotlin/net/codinux/invoicing/email/ListenForNewMailsOptions.kt @@ -16,7 +16,7 @@ open class ListenForNewMailsOptions( emailFolderName: String = "INBOX", connectTimeoutSeconds: Int = 5, - onError: ((FetchEmailsError) -> Unit)? = null, + onError: ((FetchEmailError) -> Unit)? = null, onEmailReceived: (Email) -> Unit ) : FetchEmailsOptions( null,