From 58eb117ae1d77548679ab44036010a351f62a3a2 Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Mon, 7 May 2018 17:48:33 +0300 Subject: [PATCH] Improve message of exception thrown from codegen Don't lose information about which file caused crash. --- .../kotlin/codegen/CompilationErrorHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/CompilationErrorHandler.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/CompilationErrorHandler.java index 8fd544ab10a..61fe7a02cc8 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/CompilationErrorHandler.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/CompilationErrorHandler.java @@ -16,12 +16,14 @@ package org.jetbrains.kotlin.codegen; +import org.jetbrains.kotlin.util.ExceptionUtilKt; + public interface CompilationErrorHandler { CompilationErrorHandler THROW_EXCEPTION = (exception, fileUrl) -> { - if (exception instanceof RuntimeException) { - throw (RuntimeException) exception; - } - throw new IllegalStateException(exception); + throw new IllegalStateException( + ExceptionUtilKt.getExceptionMessage("Backend", "Exception during code generation", exception, fileUrl), + exception + ); }; void reportException(Throwable exception, String fileUrl);