Preserve original stacktrace for exceptions in PyPackageUtil#refreshAndGetPackagesMod...
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Sat, 6 Aug 2016 18:31:03 +0000 (21:31 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 8 Aug 2016 12:42:45 +0000 (15:42 +0300)
The same way it's done in PythonSdkUpdater, i.e. original stacktrace
is attached as exception's cause and the whole trace is included only
with debug level of logging.

python/src/com/jetbrains/python/packaging/PyPackageUtil.java

index 0fc1b2017a35e197e6f8f902a71f834dc89863cb..387968336a608cca241e4c9d4990397421952181 100644 (file)
@@ -282,6 +282,7 @@ public class PyPackageUtil {
   @Nullable
   public static List<PyPackage> refreshAndGetPackagesModally(@NotNull Sdk sdk) {
     final Ref<List<PyPackage>> packagesRef = Ref.create();
   @Nullable
   public static List<PyPackage> refreshAndGetPackagesModally(@NotNull Sdk sdk) {
     final Ref<List<PyPackage>> packagesRef = Ref.create();
+    @SuppressWarnings("ThrowableInstanceNeverThrown") final Throwable callStacktrace = new Throwable();
     LOG.debug("Showing modal progress for collecting installed packages", new Throwable());
     PyUtil.runWithProgress(null, PyBundle.message("sdk.scanning.installed.packages"), true, false, indicator -> {
       indicator.setIndeterminate(true);
     LOG.debug("Showing modal progress for collecting installed packages", new Throwable());
     PyUtil.runWithProgress(null, PyBundle.message("sdk.scanning.installed.packages"), true, false, indicator -> {
       indicator.setIndeterminate(true);
@@ -289,7 +290,13 @@ public class PyPackageUtil {
         packagesRef.set(PyPackageManager.getInstance(sdk).refreshAndGetPackages(false));
       }
       catch (ExecutionException e) {
         packagesRef.set(PyPackageManager.getInstance(sdk).refreshAndGetPackages(false));
       }
       catch (ExecutionException e) {
-        LOG.warn(e);
+        if (LOG.isDebugEnabled()) {
+          e.initCause(callStacktrace);
+          LOG.debug(e);
+        }
+        else {
+          LOG.warn(e.getMessage());
+        }
       }
     });
     return packagesRef.get();
       }
     });
     return packagesRef.get();