Skip to content

Commit 55493fa

Browse files
Flanker-MSFTFlanker-MSFT
authored andcommitted
Swallow exception when get path for module
1 parent 88ed93d commit 55493fa

File tree

1 file changed

+9
-3
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/util

1 file changed

+9
-3
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/main/java/com/microsoft/intellij/util/PluginUtil.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import lombok.extern.slf4j.Slf4j;
3434
import org.apache.commons.lang3.ArrayUtils;
3535

36+
import javax.annotation.Nullable;
3637
import javax.swing.Icon;
3738

3839
import java.io.File;
@@ -87,10 +88,15 @@ public static Module getSelectedModule() {
8788
return DataKeys.MODULE.getData(dataContext);
8889
}
8990

91+
@Nullable
9092
public static String getModulePath(Module module) {
91-
return Optional.of(ModuleRootManager.getInstance(module).getContentRoots())
92-
.filter(ArrayUtils::isNotEmpty)
93-
.map(array -> array[0].getPath()).orElse(null);
93+
try {
94+
return Optional.of(ModuleRootManager.getInstance(module).getContentRoots())
95+
.filter(ArrayUtils::isNotEmpty)
96+
.map(array -> array[0].getPath()).orElse(null);
97+
} catch (Exception e) {
98+
return null;
99+
}
94100
}
95101

96102
/**

0 commit comments

Comments
 (0)