Don't wrap ProcessCanceledException with other exceptions
ProcessCanceledException indicates that the compilation process was terminated by user. This kind of exception should not be wrapped anyhow in order to be handled on toplevel in CLICompiler. #KT-38483 Fixed
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.backend.common
|
package org.jetbrains.kotlin.backend.common
|
||||||
|
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
|
import com.intellij.openapi.progress.ProcessCanceledException
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
@@ -236,6 +237,7 @@ object CodegenUtil {
|
|||||||
// CompilationException (the only KotlinExceptionWithAttachments possible here) is already supposed
|
// CompilationException (the only KotlinExceptionWithAttachments possible here) is already supposed
|
||||||
// to have all information about the context.
|
// to have all information about the context.
|
||||||
if (exception is KotlinExceptionWithAttachments) throw exception
|
if (exception is KotlinExceptionWithAttachments) throw exception
|
||||||
|
if (exception is ProcessCanceledException) throw exception
|
||||||
throw BackendException(
|
throw BackendException(
|
||||||
getExceptionMessage("Backend", "Exception during $phase", exception, location) +
|
getExceptionMessage("Backend", "Exception during $phase", exception, location) +
|
||||||
additionalMessage?.let { "\n" + it }.orEmpty(),
|
additionalMessage?.let { "\n" + it }.orEmpty(),
|
||||||
|
|||||||
+13
-9
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.common
|
package org.jetbrains.kotlin.backend.common
|
||||||
|
|
||||||
|
import com.intellij.openapi.progress.ProcessCanceledException
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||||
@@ -96,13 +97,16 @@ fun Throwable.wrapWithCompilationException(
|
|||||||
message: String,
|
message: String,
|
||||||
file: IrFile,
|
file: IrFile,
|
||||||
element: IrElement?
|
element: IrElement?
|
||||||
): CompilationException {
|
): RuntimeException {
|
||||||
return CompilationException(
|
return if (this is ProcessCanceledException)
|
||||||
"$message: ${this::class.qualifiedName}: ${this.message}",
|
this
|
||||||
file,
|
else
|
||||||
element,
|
CompilationException(
|
||||||
cause = this
|
"$message: ${this::class.qualifiedName}: ${this.message}",
|
||||||
).apply {
|
file,
|
||||||
stackTrace = this@wrapWithCompilationException.stackTrace
|
element,
|
||||||
}
|
cause = this
|
||||||
|
).apply {
|
||||||
|
stackTrace = this@wrapWithCompilationException.stackTrace
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+3
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.jvm.codegen
|
package org.jetbrains.kotlin.backend.jvm.codegen
|
||||||
|
|
||||||
|
import com.intellij.openapi.progress.ProcessCanceledException
|
||||||
import org.jetbrains.kotlin.backend.common.lower.BOUND_RECEIVER_PARAMETER
|
import org.jetbrains.kotlin.backend.common.lower.BOUND_RECEIVER_PARAMETER
|
||||||
import org.jetbrains.kotlin.backend.common.lower.BOUND_VALUE_PARAMETER
|
import org.jetbrains.kotlin.backend.common.lower.BOUND_VALUE_PARAMETER
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||||
@@ -42,6 +43,8 @@ class FunctionCodegen(private val irFunction: IrFunction, private val classCodeg
|
|||||||
): SMAPAndMethodNode =
|
): SMAPAndMethodNode =
|
||||||
try {
|
try {
|
||||||
doGenerate(reifiedTypeParameters)
|
doGenerate(reifiedTypeParameters)
|
||||||
|
} catch (e: ProcessCanceledException) {
|
||||||
|
throw e
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
throw RuntimeException("Exception while generating code for:\n${irFunction.dump()}", e)
|
throw RuntimeException("Exception while generating code for:\n${irFunction.dump()}", e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user