Catching all errors
This commit is contained in:
parent
2cbe323e9b
commit
f6a0022b24
|
@ -101,21 +101,20 @@ class MailReader(
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryToReadEInvoice(part: BodyPart): Invoice? {
|
private fun tryToReadEInvoice(part: BodyPart): Invoice? = try {
|
||||||
val filename = part.fileName.lowercase()
|
val filename = part.fileName.lowercase()
|
||||||
val contentType = part.contentType.lowercase()
|
val contentType = part.contentType.lowercase()
|
||||||
|
|
||||||
return if (filename.endsWith(".pdf") || contentType.startsWith("application/pdf") || contentType.startsWith("application/octet-stream")) {
|
if (filename.endsWith(".pdf") || contentType.startsWith("application/pdf") || contentType.startsWith("application/octet-stream")) {
|
||||||
try {
|
eInvoiceReader.extractFromPdf(part.inputStream)
|
||||||
eInvoiceReader.extractFromPdf(part.inputStream)
|
|
||||||
} catch (e: Throwable) {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
} else if (filename.endsWith(".xml") || contentType.startsWith("application/xml") || contentType.startsWith("text/xml")) {
|
} else if (filename.endsWith(".xml") || contentType.startsWith("application/xml") || contentType.startsWith("text/xml")) {
|
||||||
eInvoiceReader.readFromXml(part.inputStream)
|
eInvoiceReader.readFromXml(part.inputStream)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
log.debug(e) { "Could not extract invoices from ${part.fileName}" }
|
||||||
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: same code as in MustangMapper
|
// TODO: same code as in MustangMapper
|
||||||
|
|
Loading…
Reference in New Issue