private ErrorBean createErrorBean(IdeaLoggingEvent loggingEvent, String additionalInfo) {
   ErrorBean errorBean = new ErrorBean();
   errorBean.setAdditionInfo(additionalInfo);
   errorBean.setPluginVersion(Version.get());
   ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
   String intellijVersion =
       String.format(
           "%s %s.%s",
           appInfo.getVersionName(), appInfo.getMajorVersion(), appInfo.getMinorVersion());
   errorBean.setIntellijVersion(intellijVersion);
   errorBean.setException(loggingEvent.getThrowableText());
   errorBean.setExceptionMessage(loggingEvent.getMessage());
   return errorBean;
 }
Ejemplo n.º 2
0
  private static boolean doSubmit(
      final IdeaLoggingEvent event,
      final Component parentComponent,
      final Consumer<SubmittedReportInfo> callback,
      final ErrorBean bean,
      final String description) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);

    bean.setDescription(description);
    bean.setMessage(event.getMessage());

    Throwable throwable = event.getThrowable();
    if (throwable != null) {
      final PluginId pluginId = IdeErrorsDialog.findPluginId(throwable);
      if (pluginId != null) {
        final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
        if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
          bean.setPluginName(ideaPluginDescriptor.getName());
          bean.setPluginVersion(ideaPluginDescriptor.getVersion());
        }
      }
    }

    Object data = event.getData();

    if (data instanceof LogMessageEx) {
      bean.setAttachments(((LogMessageEx) data).getAttachments());
    }

    LinkedHashMap<String, String> reportValues =
        IdeaITNProxy.getKeyValuePairs(
            bean,
            ApplicationManager.getApplication(),
            (ApplicationInfoEx) ApplicationInfo.getInstance(),
            ApplicationNamesInfo.getInstance());

    final Project project = CommonDataKeys.PROJECT.getData(dataContext);

    Consumer<String> successCallback =
        new Consumer<String>() {
          @Override
          public void consume(String token) {
            final SubmittedReportInfo reportInfo =
                new SubmittedReportInfo(
                    null, "Issue " + token, SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
            callback.consume(reportInfo);

            ReportMessages.GROUP
                .createNotification(
                    ReportMessages.ERROR_REPORT, "Submitted", NotificationType.INFORMATION, null)
                .setImportant(false)
                .notify(project);
          }
        };

    Consumer<Exception> errorCallback =
        new Consumer<Exception>() {
          @Override
          public void consume(Exception e) {
            String message = GoBundle.message("go.error.report.message", e.getMessage());
            ReportMessages.GROUP
                .createNotification(
                    ReportMessages.ERROR_REPORT,
                    message,
                    NotificationType.ERROR,
                    NotificationListener.URL_OPENING_LISTENER)
                .setImportant(false)
                .notify(project);
          }
        };
    AnonymousFeedbackTask task =
        new AnonymousFeedbackTask(
            project, "Submitting error report", true, reportValues, successCallback, errorCallback);
    if (project == null) {
      task.run(new EmptyProgressIndicator());
    } else {
      ProgressManager.getInstance().run(task);
    }
    return true;
  }