Add error function taking a throwable to LoggerBase

This commit is contained in:
Chris Smowton
2024-11-27 16:29:31 +00:00
parent dfad8c8475
commit bfdb5e0b17
2 changed files with 6 additions and 2 deletions

View File

@@ -292,7 +292,7 @@ fun doAnalysis(
// stack overflow or an assertion failure in one file.
} catch (e: Throwable) {
fileExtractionProblems.setNonRecoverableProblem()
loggerBase.error(dtw, "Extraction failed while extracting '${psiFile.virtualFilePath}'.", e.stackTraceToString())
loggerBase.error(dtw, "Extraction failed while extracting '${psiFile.virtualFilePath}'.", e)
}
} else {
System.out.println("Warning: Not a KtFile")

View File

@@ -286,6 +286,10 @@ class LoggerBase(val diagnosticCounter: DiagnosticCounter) : BasicLogger {
error(dtw, msg, extraInfo, null)
}
fun error(dtw: DiagnosticTrapWriter, msg: String, exn: Throwable) {
error(dtw, msg, exn.stackTraceToString())
}
fun error(dtw: DiagnosticTrapWriter, msg: String, extraInfo: String?, loggerState: LoggerState?) {
if (verbosity >= 1) {
diagnostic(dtw, Severity.Error, msg, extraInfo, loggerState)
@@ -385,7 +389,7 @@ open class Logger(val loggerBase: LoggerBase, val dtw: DiagnosticTrapWriter) : B
}
fun error(msg: String, exn: Throwable) {
error(msg, exn.stackTraceToString())
loggerBase.error(dtw, msg, exn)
}
}