IR: wrap exceptions and add file path in per-file lowerings

Also add file path to the wrapped exception in JVM IR codegen
This commit is contained in:
Alexander Udalov
2019-11-28 19:17:30 +01:00
parent fd627603a0
commit 2552540f71
7 changed files with 27 additions and 66 deletions
@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.multiplatform.ExpectedActualResolver
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.util.getExceptionMessage
import org.jetbrains.kotlin.utils.DFS
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
object CodegenUtil {
@JvmStatic
@@ -236,4 +238,15 @@ object CodegenUtil {
{ it.declaresDefaultValue() }
)
}
@JvmStatic
fun reportBackendException(exception: Throwable, phase: String, fileUrl: String?): Nothing {
// CompilationException (the only KotlinExceptionWithAttachments possible here) is already supposed
// to have all information about the context.
if (exception is KotlinExceptionWithAttachments) throw exception
throw IllegalStateException(
getExceptionMessage("Backend", "Exception during $phase", exception, fileUrl),
exception
)
}
}