Skip to content

Commit f4bb618

Browse files
BoDmartinbonnin
authored andcommitted
[IJ plugin] Avoid a crash caught in inspection (#5139)
1 parent 6481213 commit f4bb618

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/navigation/compat/KotlinFindUsagesHandlerFactoryCompat.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,13 @@ class KotlinFindUsagesHandlerFactoryCompat(project: Project) : FindUsagesHandler
2222
.onFailure { logw(it, "Could not load either $POST_231_CLASS_NAME nor $PRE_231_CLASS_NAME") }
2323
.getOrNull()
2424

25-
private val delegate: FindUsagesHandlerFactory? = delegateClass?.let { it.getConstructor(Project::class.java).newInstance(project) as FindUsagesHandlerFactory }
25+
private val delegate: FindUsagesHandlerFactory? = try {
26+
delegateClass?.let { it.getConstructor(Project::class.java).newInstance(project) as FindUsagesHandlerFactory }
27+
} catch (e: Exception) {
28+
// ProcessCanceledException can sometimes happen here
29+
logw(e, "Could not instantiate KotlinFindUsagesHandlerFactory")
30+
null
31+
}
2632

2733

2834
override fun canFindUsages(element: PsiElement): Boolean {

0 commit comments

Comments
 (0)