collects all literal decode errors falling through the logging cracks

This commit is contained in:
Fate-JH 2023-12-18 21:26:12 -05:00
parent a2134d820b
commit 284715d9a1
3 changed files with 18 additions and 7 deletions

View file

@ -98,8 +98,9 @@ object ObjectCreateBase {
}
} catch {
case ex: Exception =>
log.error(s"Decoding error - ${ex.getClass.toString} - ${ex.toString} ($objectClass)")
Attempt.failure(Err(ex.getMessage))
val msg = s"Decoding error - ${ex.toString} ($objectClass)"
log.error(msg)
Attempt.failure(Err(msg))
}
}

View file

@ -129,7 +129,7 @@ object DecodePackets {
//delete just the files that were created (if files were overwrote, nothing we can do)
val (deleteThese, _) = filesWithSameNameAs(
files,
getAllFilePathsFromDirectory(tmpFolder.getAbsolutePath).map(_.toFile)
getAllFilePathsFromDirectory(tmpFolder.getAbsolutePath).toIndexedSeq.map(_.toFile)
)
deleteThese.foreach(FileUtils.forceDelete)
}
@ -147,7 +147,7 @@ object DecodePackets {
*/
private def filesWithSameNameInDirectory(directory: String, files: Seq[File]): (Seq[File], Seq[File]) = {
filesWithSameNameAs(
getAllFilePathsFromDirectory(directory).map(_.toFile),
getAllFilePathsFromDirectory(directory).toIndexedSeq.map(_.toFile),
files
)
}
@ -327,8 +327,9 @@ object DecodePackets {
if (i == 0) writer.write("> ")
else writer.write("-")
}
val nextDecodedLine = decodePacket(header="", packet).text
writer.write(nextDecodedLine)
val nextDecoded = decodePacket(decodedLine, packet)
val nextDecodedLine = nextDecoded.text
writer.write(nextDecoded)
writer.newLine()
if (isNestedPacket(nextDecodedLine)) {
linesToSkip += recursivelyHandleNestedPacket(nextDecodedLine, writer, depth + 1)

View file

@ -37,7 +37,13 @@ final case class DecodeErrorWriter(directoryPath: String, fileName: String)
private val log: DecodeWriter = DecodeWriter(directoryPath, fileName)
private val errorLog: DecodeWriter = DecodeWriter(directoryPath, fileName+".error")
def write(str: String): Unit = log.write(str)
def write(str: String): Unit = {
log.write(str)
if (str.contains("Decoding error")) {
errorLog.write(str)
errorLog.newLine()
}
}
def write(data: PacketOutput): Unit = {
log.write(data)
@ -46,6 +52,9 @@ final case class DecodeErrorWriter(directoryPath: String, fileName: String)
case error: DecodeError =>
errorLog.write(error)
errorLog.newLine()
case result if result.text.contains("Decoding error") =>
errorLog.write(data)
errorLog.newLine()
case _ => ()
}
}