Implemented catching exceptions in removeSensitiveDataFromMessage()

This commit is contained in:
dankito 2020-12-06 22:34:02 +01:00
parent 754811ad55
commit 66f4eeb6ad
1 changed files with 9 additions and 1 deletions

View File

@ -23,7 +23,7 @@ open class MessageLogCollector {
// in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData // in either case remove sensitive data after response is parsed as otherwise some information like account holder name and accounts may is not set yet on BankData
open val messageLogWithoutSensitiveData: List<MessageLogEntry> open val messageLogWithoutSensitiveData: List<MessageLogEntry>
get() = messageLog.map { MessageLogEntry(removeSensitiveDataFromMessage(it.message, it.bank), it.type, it.time, it.bank) } get() = messageLog.map { MessageLogEntry(safelyRemoveSensitiveDataFromMessage(it.message, it.bank), it.type, it.time, it.bank) }
open fun addMessageLog(message: String, type: MessageLogEntryType, bank: BankData) { open fun addMessageLog(message: String, type: MessageLogEntryType, bank: BankData) {
@ -56,6 +56,14 @@ open class MessageLogCollector {
} }
protected open fun safelyRemoveSensitiveDataFromMessage(message: String, bank: BankData?): String {
try {
return removeSensitiveDataFromMessage(message, bank)
} catch (e: Exception) {
return "! WARNING !\r\nCould not remove sensitive data!\r\n$e\r\n$message"
}
}
protected open fun removeSensitiveDataFromMessage(message: String, bank: BankData?): String { protected open fun removeSensitiveDataFromMessage(message: String, bank: BankData?): String {
if (bank == null) { if (bank == null) {
return message return message