Example usage for com.intellij.openapi.diagnostic IdeaLoggingEvent getThrowableText

List of usage examples for com.intellij.openapi.diagnostic IdeaLoggingEvent getThrowableText

Introduction

In this page you can find the example usage for com.intellij.openapi.diagnostic IdeaLoggingEvent getThrowableText.

Prototype

public String getThrowableText() 

Source Link

Usage

From source file:com.atlassian.theplugin.idea.BlameAtlassian.java

License:Apache License

public SubmittedReportInfo submit(IdeaLoggingEvent[] ideaLoggingEvents, Component component) {
    StringBuilder description = new StringBuilder();
    for (IdeaLoggingEvent ideaLoggingEvent : ideaLoggingEvents) {
        description.append(ideaLoggingEvent.getMessage());
        description.append("\n");
        description.append(ideaLoggingEvent.getThrowableText());
        description.append("\n");
    }//w w  w . j a  v  a2 s  .  co  m

    // there is no getBuild().asString() in IDEA 8.0 and older, so we need to use
    // deprecated getBuildNumber() method here...
    @SuppressWarnings("deprecation")
    String buildNumber = ApplicationInfo.getInstance().getBuildNumber();
    BrowserUtil.launchBrowser(BugReporting.getBugWithDescriptionUrl(buildNumber, description.toString()));

    return new SubmittedReportInfo(null, "JIRA ticket", SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
}

From source file:com.intellij.diagnostic.ITNReporter.java

License:Apache License

private SubmittedReportInfo doSubmit(IdeaLoggingEvent[] ideaLoggingEvents, String addInfo,
        Component component) {//from  w ww .  j  av  a2s  . c  om
    final DataContext dataContext = DataManager.getInstance().getDataContext(component);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final IdeaLoggingEvent ideaLoggingEvent = ideaLoggingEvents[0];
    final String throwableText = ideaLoggingEvent.getThrowableText();
    String description = throwableText.substring(0, Math.min(Math.max(80, throwableText.length()), 80));

    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    Integer signature = ideaLoggingEvent.getThrowable().getStackTrace()[0].hashCode();

    String existing = findExisting(signature);
    if (existing != null) {
        final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + existing,
                existing, DUPLICATE);
        popupResultInfo(reportInfo, project);
        return reportInfo;
    }

    @NonNls
    StringBuilder descBuilder = new StringBuilder();

    descBuilder.append("Build: ").append(ApplicationInfo.getInstance().getBuild()).append('\n');
    descBuilder.append("OS: ").append(SystemInfo.OS_NAME).append(" ").append(SystemInfo.OS_ARCH).append(" ")
            .append(SystemInfo.OS_VERSION).append('\n');
    descBuilder.append("Java Vendor: ").append(SystemProperties.getJavaVmVendor()).append('\n');
    descBuilder.append("Java Version: ").append(SystemInfo.JAVA_VERSION).append('\n');
    descBuilder.append("Java Arch: ").append(SystemInfo.ARCH_DATA_MODEL).append('\n');
    descBuilder.append("Java Runtime Version: ").append(SystemInfo.JAVA_RUNTIME_VERSION).append('\n');

    String affectedVersion = null;
    Throwable t = ideaLoggingEvent.getThrowable();
    final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
    if (pluginId != null) {
        final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
        if (ideaPluginDescriptor != null) {
            descBuilder.append("Plugin ").append(ideaPluginDescriptor.getName()).append(" version: ")
                    .append(ideaPluginDescriptor.getVersion()).append("\n");
            affectedVersion = ideaPluginDescriptor.getVersion();
        }
    }

    if (addInfo == null) {
        addInfo = "<none>";
    }

    descBuilder.append("Description: ").append(addInfo);

    for (IdeaLoggingEvent e : ideaLoggingEvents) {
        descBuilder.append("\n\n").append(e.toString());
    }

    String result = submit(description, descBuilder.toString(), affectedVersion);
    LOGGER.info("Error submitted, response: " + result);

    if (result == null) {
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    }

    String ResultString = null;
    try {
        Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
        Matcher regexMatcher = regex.matcher(result);
        if (regexMatcher.find()) {
            ResultString = regexMatcher.group(1);
        }
    } catch (PatternSyntaxException ex) {
        // Syntax error in the regular expression
    }

    SubmittedReportInfo.SubmissionStatus status = NEW_ISSUE;

    if (ResultString == null) {
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    }

    final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString,
            ResultString, status);

    /* Now try to set the autosubmit user using a custom command */
    /* if (user != null) {
       runCommand(ResultString, "Autosubmit User " + user);
     }  */

    if (signature != 0) {
        runCommand(ResultString, "Exception Signature " + signature);
    }

    popupResultInfo(reportInfo, project);

    return reportInfo;
}

From source file:com.perl5.errorHandler.YoutrackErrorHandler.java

License:Apache License

private SubmittedReportInfo doSubmit(IdeaLoggingEvent[] ideaLoggingEvents, String addInfo,
        Component component) {/*www. jav  a2s .com*/
    final DataContext dataContext = DataManager.getInstance().getDataContext(component);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    final IdeaLoggingEvent ideaLoggingEvent = ideaLoggingEvents[0];
    final String throwableText = ideaLoggingEvent.getThrowableText();
    String description = throwableText.substring(0, Math.min(Math.max(80, throwableText.length()), 80));

    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    Integer signature = ideaLoggingEvent.getThrowable().getStackTrace()[0].hashCode();

    String existing = findExisting(signature);
    if (existing != null) {
        final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + existing,
                existing, DUPLICATE);
        popupResultInfo(reportInfo, project);
        return reportInfo;
    }

    @NonNls
    StringBuilder descBuilder = new StringBuilder();

    descBuilder.append("Build: ").append(ApplicationInfo.getInstance().getBuild()).append('\n');
    descBuilder.append("OS: ").append(SystemInfo.OS_NAME).append(" ").append(SystemInfo.OS_ARCH).append(" ")
            .append(SystemInfo.OS_VERSION).append('\n');
    descBuilder.append("Java Vendor: ").append(SystemProperties.getJavaVmVendor()).append('\n');
    descBuilder.append("Java Version: ").append(SystemInfo.JAVA_VERSION).append('\n');
    descBuilder.append("Java Arch: ").append(SystemInfo.ARCH_DATA_MODEL).append('\n');
    descBuilder.append("Java Runtime Version: ").append(SystemInfo.JAVA_RUNTIME_VERSION).append('\n');

    String affectedVersion = null;
    Throwable t = ideaLoggingEvent.getThrowable();
    final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
    if (pluginId != null) {
        final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
        if (ideaPluginDescriptor != null) {
            descBuilder.append("Plugin Version: ").append(ideaPluginDescriptor.getVersion()).append("\n");
            affectedVersion = ideaPluginDescriptor.getVersion();
        }
    }

    if (addInfo == null) {
        addInfo = "<none>";
    }

    descBuilder.append("Description: ").append(addInfo);

    for (IdeaLoggingEvent e : ideaLoggingEvents) {
        descBuilder.append("\n\n").append(e.toString());
    }

    String result = submit(description, descBuilder.toString(), affectedVersion);
    LOGGER.info("Error submitted, response: " + result);

    if (result == null) {
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    }

    String ResultString = null;
    try {
        Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
        Matcher regexMatcher = regex.matcher(result);
        if (regexMatcher.find()) {
            ResultString = regexMatcher.group(1);
        }
    } catch (PatternSyntaxException ex) {
        // Syntax error in the regular expression
    }

    SubmittedReportInfo.SubmissionStatus status = NEW_ISSUE;

    if (ResultString == null) {
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    }

    final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString,
            ResultString, status);

    /* Now try to set the autosubmit user using a custom command */
    /* if (user != null) {
      runCommand(ResultString, "Autosubmit User " + user);
     }  */

    if (signature != 0) {
        runCommand(ResultString, "Exception Signature " + signature);
    }

    popupResultInfo(reportInfo, project);

    return reportInfo;
}

From source file:com.sylvanaar.idea.errorreporting.YouTrackBugReporter.java

License:Apache License

private boolean submit(IdeaLoggingEvent[] ideaLoggingEvents, String description, String user,
        Component component, Consumer<SubmittedReportInfo> consumer) {
    final DataManager dataManager = DataManager.getInstance();
    final DataContext dataContext = dataManager != null ? dataManager.getDataContext(component) : null;
    final Project project;
    if (dataContext != null) {
        project = PlatformDataKeys.PROJECT.getData(dataContext);
    } else {/*  w w  w  .j  a  va2 s . c  om*/
        return false;
    }
    final IdeaLoggingEvent ideaLoggingEvent = ideaLoggingEvents[0];
    final String throwableText = ideaLoggingEvent.getThrowableText();
    this.description = throwableText.substring(0, Math.min(Math.max(80, throwableText.length()), 80));

    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    Integer signature = ideaLoggingEvent.getThrowable().getStackTrace()[0].hashCode();

    String existing = findExisting(signature);
    if (existing != null) {
        final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + existing,
                existing, DUPLICATE);
        popupResultInfo(reportInfo, project);
        consumer.consume(reportInfo);
        return true;
    }

    @NonNls
    StringBuilder descBuilder = new StringBuilder();

    String platformBuild = ApplicationInfo.getInstance().getBuild().asString();

    descBuilder.append("Platform Version: ").append(platformBuild).append('\n');

    Throwable t = ideaLoggingEvent.getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                descBuilder.append("Plugin ").append(ideaPluginDescriptor.getName()).append(" version: ")
                        .append(ideaPluginDescriptor.getVersion()).append("\n");
                this.affectedVersion = ideaPluginDescriptor.getVersion();
            }
        }
    }

    if (description == null) {
        description = "<none>";
    }

    descBuilder.append("\n\nDescription: ").append(description);

    for (IdeaLoggingEvent e : ideaLoggingEvents) {
        descBuilder.append("\n\n").append(e.toString());
    }

    this.extraInformation = descBuilder.toString();

    String result = submit();
    log.info("Error submitted, response: " + result);

    if (result == null) {
        return false;
    }

    String ResultString = null;
    try {
        Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
        Matcher regexMatcher = regex.matcher(result);
        if (regexMatcher.find()) {
            ResultString = regexMatcher.group(1);
        }
    } catch (PatternSyntaxException ex) {
        // Syntax error in the regular expression
    }

    SubmittedReportInfo.SubmissionStatus status = NEW_ISSUE;

    if (ResultString == null) {
        return false;
    }

    final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString,
            ResultString, status);

    /* Now try to set the autosubmit user using a custom command */
    if (user != null) {
        runCommand(ResultString, "Autosubmit User " + user);
    }

    if (signature != 0) {
        runCommand(ResultString, "Exception Signature " + signature);
    }

    popupResultInfo(reportInfo, project);

    consumer.consume(reportInfo);

    return true;
}

From source file:com.urswolfer.intellij.plugin.gerrit.errorreport.PluginErrorReportSubmitter.java

License:Apache License

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());//  w w w  .  ja v a2 s .c o m
    errorBean.setIntellijVersion(intellijVersion);
    errorBean.setException(loggingEvent.getThrowableText());
    errorBean.setExceptionMessage(loggingEvent.getMessage());
    return errorBean;
}

From source file:de.halirutan.mathematica.errorreporting.YouTrackBugReporter.java

License:Open Source License

private SubmittedReportInfo submit(IdeaLoggingEvent[] ideaLoggingEvents, String description, String user,
        Component component) {/*from  w ww.  j a  va2s  . c om*/
    final DataContext dataContext = DataManager.getInstance().getDataContext(component);
    final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    final IdeaLoggingEvent ideaLoggingEvent = ideaLoggingEvents[0];
    final String throwableText = ideaLoggingEvent.getThrowableText();
    this.myDescription = throwableText.substring(0, Math.min(Math.max(80, throwableText.length()), 80));

    @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
    Integer signature = ideaLoggingEvent.getThrowable().getStackTrace()[0].hashCode();

    String existing = findExisting(signature);
    if (existing != null) {
        final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + existing,
                existing, DUPLICATE);
        popupResultInfo(reportInfo, project);
        return reportInfo;
    }

    @NonNls
    StringBuilder descBuilder = new StringBuilder();

    String platformBuild = ApplicationInfo.getInstance().getBuild().asString();

    descBuilder.append("Platform Version: ").append(platformBuild).append('\n');

    Throwable t = ideaLoggingEvent.getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && !ideaPluginDescriptor.isBundled()) {
                descBuilder.append("Plugin ").append(ideaPluginDescriptor.getName()).append(" version: ")
                        .append(ideaPluginDescriptor.getVersion()).append("\n");
                this.myAffectedVersion = ideaPluginDescriptor.getVersion();
            }
        }
    }

    if (description == null) {
        description = "<none>";
    }

    descBuilder.append("\n\nDescription: ").append(description);

    for (IdeaLoggingEvent e : ideaLoggingEvents) {
        descBuilder.append("\n\n").append(e.toString());
    }

    this.myExtraInformation = descBuilder.toString();

    String result = submit();
    log.info("Error submitted, response: " + result);

    if (result == null) {
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    }

    String resultString = null;
    try {
        Pattern regex = Pattern.compile("id=\"([^\"]+)\"", Pattern.DOTALL | Pattern.MULTILINE);
        Matcher regexMatcher = regex.matcher(result);
        if (regexMatcher.find()) {
            resultString = regexMatcher.group(1);
        }
    } catch (PatternSyntaxException ex) {
        // Syntax error in the regular expression
    }

    SubmissionStatus status = NEW_ISSUE;

    if (resultString == null) {
        return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
    }

    final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + resultString,
            resultString, status);

    /* Now try to set the autosubmit user using a custom command */
    if (user != null) {
        runCommand(resultString, "Autosubmit User " + user);
    }

    if (signature != 0) {
        runCommand(resultString, "Exception Signature " + signature);
    }

    popupResultInfo(reportInfo, project);

    return reportInfo;
}

From source file:io.flutter.FlutterErrorReportSubmitter.java

License:Open Source License

@SuppressWarnings("deprecation")
@Override/*from   w ww  . jav  a2s. c  o m*/
public void submitAsync(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo,
        @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) {
    if (events.length == 0) {
        consumer.consume(new SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.FAILED));
        return;
    }

    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        project = ProjectManager.getInstance().getDefaultProject();
    }

    final StringBuilder builder = new StringBuilder();

    builder.append("Please file this bug report at https://github.com/flutter/flutter-intellij/issues/new.\n");
    builder.append("\n");
    builder.append("---\n");
    builder.append("\n");

    builder.append("## What happened\n");
    builder.append("\n");
    if (additionalInfo != null) {
        builder.append(additionalInfo.trim()).append("\n");
    } else {
        builder.append("(please describe what you were doing when this exception occurred)\n");
    }
    builder.append("\n");

    builder.append("## Version information\n");
    builder.append("\n");

    // IntelliJ version
    final ApplicationInfo info = ApplicationInfo.getInstance();
    builder.append(info.getVersionName()).append(" `").append(info.getFullVersion()).append("`");

    final IdeaPluginDescriptor flutterPlugin = PluginManager.getPlugin(PluginId.getId("io.flutter"));
    //noinspection ConstantConditions
    builder.append("  Flutter plugin `").append(flutterPlugin.getVersion()).append("`");

    final IdeaPluginDescriptor dartPlugin = PluginManager.getPlugin(PluginId.getId("Dart"));
    if (dartPlugin != null) {
        //noinspection ConstantConditions
        builder.append("  Dart plugin `").append(dartPlugin.getVersion()).append("`");
    }
    builder.append("\n\n");

    final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
    if (sdk == null) {
        builder.append("No Flutter sdk configured.\n");
    } else {
        final String flutterVersion = getFlutterVersion(sdk);
        if (flutterVersion != null) {
            builder.append(flutterVersion.trim()).append("\n");
        } else {
            builder.append("Error getting Flutter sdk information.\n");
        }
    }
    builder.append("\n");

    for (IdeaLoggingEvent event : events) {
        builder.append("## Exception\n");
        builder.append("\n");
        builder.append(event.getMessage()).append("\n");
        builder.append("\n");

        if (event.getThrowable() != null) {
            builder.append("```\n");
            builder.append(event.getThrowableText().trim()).append("\n");
            builder.append("```\n");
            builder.append("\n");

            FlutterInitializer.getAnalytics().sendException(event.getThrowable(), false);
        }
    }

    final String text = builder.toString().trim() + "\n";

    // Create scratch file.
    final ScratchRootType scratchRoot = ScratchRootType.getInstance();
    final VirtualFile file = scratchRoot.createScratchFile(project, "bug-report.md", Language.ANY, text);

    if (file != null) {
        // Open the file.
        new OpenFileDescriptor(project, file).navigate(true);
    } else {
        consumer.consume(new SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.FAILED));
    }

    consumer.consume(new SubmittedReportInfo(null, "", SubmittedReportInfo.SubmissionStatus.NEW_ISSUE));
}

From source file:nu.studer.idea.errorreporting.LoggingEventSubmitter.java

License:Apache License

void submit(@NotNull IdeaLoggingEvent[] events, @Nullable String description, @Nullable String user)
        throws SubmitException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("About to send logging events " + Arrays.asList(events));
    }/*from w ww .  j  a  v  a 2  s.  c  o m*/

    // open connection
    URLConnection connection;
    try {
        URL url = new URL(serverURL);
        connection = url.openConnection();
        connection.setRequestProperty("Content-type", "application/octet-stream");
        connection.setConnectTimeout(15 * 1000);
        connection.setReadTimeout(15 * 1000);
        connection.setUseCaches(false);
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.connect();
        connection.getOutputStream();
    } catch (IOException ioe) {
        LOGGER.info("Unable to connect to server", ioe);
        throw new SubmitException("Unable to connect to server", ioe);
    }

    // write events to server
    DataOutputStream stream = null;
    try {
        stream = new DataOutputStream(new DeflaterOutputStream(connection.getOutputStream()));
        stream.writeUTF(pluginId != null ? pluginId : "");
        stream.writeUTF(pluginName != null ? pluginName : "");
        stream.writeUTF(pluginVersion != null ? pluginVersion : "");
        stream.writeUTF(ideaBuild != null ? ideaBuild : "");
        stream.writeUTF(emailTo != null ? StringUtil.join(emailTo, ":") : "");
        stream.writeUTF(emailCc != null ? StringUtil.join(emailCc, ":") : "");
        stream.writeUTF(user != null ? user : "");
        stream.writeUTF(description != null ? description : "");
        stream.writeInt(events.length);
        for (IdeaLoggingEvent event : events) {
            stream.writeUTF(event.getMessage() != null ? event.getMessage() : "");
            stream.writeUTF(event.getThrowableText() != null ? event.getThrowableText() : "");
        }
        stream.flush();
    } catch (IOException ioe) {
        LOGGER.info("Unable to send data to server", ioe);
        throw new SubmitException("Unable to send data to server", ioe);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException ioe) {
                LOGGER.info("Unable to disconnect from server after sending data", ioe);
            }
        }
    }

    LOGGER.debug("Logging events sent successfully");

    // read response from server
    DataInputStream inputStream;
    try {
        inputStream = new DataInputStream(new InflaterInputStream(connection.getInputStream()));
        boolean statusOK = inputStream.readBoolean();
        String statusMessage = inputStream.readUTF();

        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Status OK: " + statusOK);
            LOGGER.debug("Status message: " + statusMessage);
        }

        if (!statusOK) {
            LOGGER.info("Status returned by server is NOK");
            throw new SubmitException(statusMessage, null);
        } else {
            LOGGER.info("Status returned by server is OK");
        }
    } catch (IOException ioe) {
        LOGGER.info("Unable to receive data from server", ioe);
        throw new SubmitException("Unable to receive data from server", ioe);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException ioe) {
                LOGGER.info("Unable to disconnect from server after receiving data", ioe);
            }
        }
    }

    // disconnect connection
    if (connection instanceof HttpURLConnection) {
        HttpURLConnection httpConnection = (HttpURLConnection) connection;
        try {
            int responseCode = httpConnection.getResponseCode();
            String responseMessage = httpConnection.getResponseMessage();

            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Response code: " + responseCode);
                LOGGER.debug("Response message: " + responseMessage);
            }
        } catch (IOException ioe) {
            LOGGER.info("Unable to retrieve response status");
        } finally {
            httpConnection.disconnect();
        }
    }
}

From source file:nu.studer.idea.errorreporting.PluginErrorReportSubmitter.java

License:Apache License

@Override
public SubmittedReportInfo submit(IdeaLoggingEvent[] events, final Component parentComponent) {
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);

    StringBuilder stacktrace = new StringBuilder();
    for (IdeaLoggingEvent event : events) {
        stacktrace.append(event.getMessage()).append("\n");
        stacktrace.append(event.getThrowableText()).append("\n");
    }/*from   w ww  .j ava2s  .  com*/

    Properties properties = new Properties();
    queryPluginDescriptor(getPluginDescriptor(), properties);

    StringBuilder versionId = new StringBuilder();
    versionId.append(properties.getProperty(PLUGIN_ID_PROPERTY_KEY)).append(" ")
            .append(properties.getProperty(PLUGIN_VERSION_PROPERTY_KEY));
    versionId.append(", ").append(ApplicationInfo.getInstance().getBuild().asString());

    // show modal error submission dialog
    PluginErrorSubmitDialog dialog = new PluginErrorSubmitDialog(parentComponent);
    dialog.prepare("", stacktrace.toString(), versionId.toString());
    dialog.show();

    final SubmittedReportInfo[] result = { null };

    // submit error to server if user pressed SEND
    int code = dialog.getExitCode();
    if (code == DialogWrapper.OK_EXIT_CODE) {
        dialog.persist();

        String description = dialog.getDescription();
        String user = dialog.getUser();
        String editedStacktrace = dialog.getStackTrace();

        submitToServer(project, editedStacktrace, description, user, new Consumer<SubmittedReportInfo>() {
            @Override
            public void consume(SubmittedReportInfo submittedReportInfo) {
                result[0] = submittedReportInfo;
                //Messages.showInfoMessage(parentComponent, PluginErrorReportSubmitterBundle.message("successful.dialog.message"), PluginErrorReportSubmitterBundle.message("successful.dialog.title"));
            }
        }, new Consumer<Throwable>() {
            @Override
            public void consume(Throwable throwable) {
                LOGGER.info("Error submission failed", throwable);
                result[0] = new SubmittedReportInfo("http://www.ansorg-it.com/en/products_bashsupport.html",
                        "BashSupport", SubmittedReportInfo.SubmissionStatus.FAILED);
            }
        });
    }

    return result[0];
}

From source file:org.sonar.ide.idea.BlameSonar.java

License:Open Source License

@Override
public SubmittedReportInfo submit(IdeaLoggingEvent[] ideaLoggingEvents, Component component) {
    // TODO/*from ww w.  ja v a  2s . co  m*/
    StringBuilder description = new StringBuilder();
    for (IdeaLoggingEvent ideaLoggingEvent : ideaLoggingEvents) {
        description.append(ideaLoggingEvent.getMessage()).append('\n');
        description.append(ideaLoggingEvent.getThrowableText()).append('\n');
    }
    BrowserUtil.launchBrowser("mailto:user@sonar.codehaus.org", description.toString());
    return new SubmittedReportInfo(null, "Error report", SubmittedReportInfo.SubmissionStatus.NEW_ISSUE);
}