[Scripting] Pass exception when constructing ScriptDiagnostic

This commit is contained in:
Ilya Muradyan
2022-05-05 22:48:53 +03:00
committed by Space
parent 0d0d7a9659
commit 537ae662d7
3 changed files with 12 additions and 6 deletions
@@ -12,12 +12,16 @@ import kotlin.script.experimental.api.ResultWithDiagnostics
import kotlin.script.experimental.api.ScriptDiagnostic
import kotlin.script.experimental.api.SourceCode
fun makeResolveFailureResult(message: String, location: SourceCode.LocationWithId? = null) = makeResolveFailureResult(listOf(message), location)
fun makeResolveFailureResult(message: String, location: SourceCode.LocationWithId? = null) =
makeResolveFailureResult(listOf(message), location)
fun makeResolveFailureResult(messages: Iterable<String>, location: SourceCode.LocationWithId? = null) =
makeResolveFailureResult(messages, location, null)
fun makeResolveFailureResult(messages: Iterable<String>, location: SourceCode.LocationWithId?, throwable: Throwable?) =
ResultWithDiagnostics.Failure(
messages.map {
ScriptDiagnostic(ScriptDiagnostic.unspecifiedError, it, ScriptDiagnostic.Severity.WARNING, location)
ScriptDiagnostic(ScriptDiagnostic.unspecifiedError, it, ScriptDiagnostic.Severity.WARNING, location, throwable)
}
)