コード例 #1
0
 @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
 @Nullable
 private static String extractDetails(@NotNull Throwable e) {
   final Throwable unwrapped = RemoteUtil.unwrap(e);
   if (unwrapped instanceof GradleApiException) {
     return ((GradleApiException) unwrapped).getOriginalReason();
   }
   return null;
 }
コード例 #2
0
 /**
  * {@link RemoteUtil#unwrap(Throwable) unwraps} given exception if possible and builds error
  * message for it.
  *
  * @param e exception to process
  * @return error message for the given exception
  */
 @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"})
 @NotNull
 public static String buildErrorMessage(@NotNull Throwable e) {
   Throwable unwrapped = RemoteUtil.unwrap(e);
   String reason = unwrapped.getLocalizedMessage();
   if (!StringUtil.isEmpty(reason)) {
     return reason;
   } else if (unwrapped.getClass() == GradleApiException.class) {
     return String.format(
         "gradle api threw an exception: %s",
         ((GradleApiException) unwrapped).getOriginalReason());
   } else {
     StringWriter writer = new StringWriter();
     unwrapped.printStackTrace(new PrintWriter(writer));
     return writer.toString();
   }
 }