diff --git a/src/main/kotlin/creator/custom/CustomPlatformStep.kt b/src/main/kotlin/creator/custom/CustomPlatformStep.kt index baccb9175..9323d4990 100644 --- a/src/main/kotlin/creator/custom/CustomPlatformStep.kt +++ b/src/main/kotlin/creator/custom/CustomPlatformStep.kt @@ -26,13 +26,13 @@ import com.demonwav.mcdev.creator.custom.providers.EmptyLoadedTemplate import com.demonwav.mcdev.creator.custom.providers.LoadedTemplate import com.demonwav.mcdev.creator.custom.providers.TemplateProvider import com.demonwav.mcdev.creator.modalityState +import com.demonwav.mcdev.util.getOrLogException import com.intellij.ide.wizard.AbstractNewProjectWizardStep import com.intellij.ide.wizard.GitNewProjectWizardData import com.intellij.ide.wizard.NewProjectWizardBaseData import com.intellij.ide.wizard.NewProjectWizardStep import com.intellij.openapi.application.EDT import com.intellij.openapi.application.asContextElement -import com.intellij.openapi.diagnostic.getOrLogException import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.observable.properties.GraphProperty import com.intellij.openapi.observable.util.transform @@ -50,8 +50,6 @@ import com.intellij.ui.dsl.builder.bindText import com.intellij.util.application import com.intellij.util.ui.AsyncProcessIcon import javax.swing.JLabel -import kotlin.collections.component1 -import kotlin.collections.component2 import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Job import kotlinx.coroutines.cancel diff --git a/src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt b/src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt index 88444bb5d..df576ae0f 100644 --- a/src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt +++ b/src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt @@ -25,7 +25,7 @@ import com.demonwav.mcdev.creator.custom.PropertyDerivationSelect import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.creator.custom.types.CreatorProperty -import com.intellij.openapi.diagnostic.getOrLogException +import com.demonwav.mcdev.util.getOrLogException import com.intellij.openapi.diagnostic.thisLogger class SelectPropertyDerivation( diff --git a/src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt b/src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt index 9c9016db1..2730b6c53 100644 --- a/src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt +++ b/src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt @@ -26,7 +26,7 @@ import com.demonwav.mcdev.creator.custom.TemplateEvaluator import com.demonwav.mcdev.creator.custom.TemplatePropertyDescriptor import com.demonwav.mcdev.creator.custom.TemplateValidationReporter import com.demonwav.mcdev.util.SemanticVersion -import com.intellij.openapi.diagnostic.getOrLogException +import com.demonwav.mcdev.util.getOrLogException import com.intellij.openapi.diagnostic.thisLogger import com.intellij.openapi.observable.properties.GraphProperty import com.intellij.ui.ComboboxSpeedSearch diff --git a/src/main/kotlin/util/utils.kt b/src/main/kotlin/util/utils.kt index 2e80c95b5..cb984ef09 100644 --- a/src/main/kotlin/util/utils.kt +++ b/src/main/kotlin/util/utils.kt @@ -50,6 +50,7 @@ import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiFile import java.lang.invoke.MethodHandles import java.util.Locale +import java.util.concurrent.CancellationException import kotlin.math.min import kotlin.reflect.KClass import org.jetbrains.annotations.NonNls @@ -393,6 +394,19 @@ inline fun runCatchingKtIdeaExceptions(action: () -> T): T? = try { } } +fun Result.getOrLogException(logger: Logger): T? { + return getOrLogException(logger::error) +} + +inline fun Result.getOrLogException(log: (Throwable) -> Unit): T? { + return onFailure { e -> + if (e is ProcessCanceledException || e is CancellationException) { + throw e + } + log(e) + }.getOrNull() +} + fun withSuppressed(original: T?, other: T): T = original?.apply { addSuppressed(other) } ?: other