User: rednesto Date: 13 Sep 24 12:08 Revision: 7093a23f26060dbcfb6422c16375a4023aed9d1f Summary: Use our own getOrLogException These methods became Internal in 2024.3 TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9686&personal=false Index: src/main/kotlin/creator/custom/CustomPlatformStep.kt =================================================================== --- src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision 560c78abc41bc6cb9213c319122a49351a3d5a5e) +++ src/main/kotlin/creator/custom/CustomPlatformStep.kt (revision 7093a23f26060dbcfb6422c16375a4023aed9d1f) @@ -26,13 +26,13 @@ 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.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 Index: src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt =================================================================== --- src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt (revision 560c78abc41bc6cb9213c319122a49351a3d5a5e) +++ src/main/kotlin/creator/custom/derivation/SelectPropertyDerivation.kt (revision 7093a23f26060dbcfb6422c16375a4023aed9d1f) @@ -25,7 +25,7 @@ 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( Index: src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt =================================================================== --- src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt (revision 560c78abc41bc6cb9213c319122a49351a3d5a5e) +++ src/main/kotlin/creator/custom/types/MavenArtifactVersionCreatorProperty.kt (revision 7093a23f26060dbcfb6422c16375a4023aed9d1f) @@ -26,7 +26,7 @@ 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 Index: src/main/kotlin/util/utils.kt =================================================================== --- src/main/kotlin/util/utils.kt (revision 560c78abc41bc6cb9213c319122a49351a3d5a5e) +++ src/main/kotlin/util/utils.kt (revision 7093a23f26060dbcfb6422c16375a4023aed9d1f) @@ -50,6 +50,7 @@ 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 @@ -392,6 +393,19 @@ } } +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