Search in sources :

Example 1 with ErrorBean

use of com.intellij.errorreport.bean.ErrorBean in project smali by JesusFreke.

the class ErrorReporter method submit.

@Override
public boolean submit(IdeaLoggingEvent[] events, String additionalInfo, Component parentComponent, final Consumer<SubmittedReportInfo> consumer) {
    IdeaLoggingEvent event = events[0];
    ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    bean.setDescription(additionalInfo);
    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());
    }
    Map<String, String> reportValues = ITNProxy.createParameters(bean);
    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);
            consumer.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 = String.format("<html>There was an error while creating a GitHub issue: %s<br>" + "Please consider manually creating an issue on the " + "<a href=\"https://github.com/JesusFreke/smali/issues\">Smali Issue Tracker</a></html>", e.getMessage());
            ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project);
        }
    };
    GithubFeedbackTask task = new GithubFeedbackTask(project, "Submitting error report", true, reportValues, successCallback, errorCallback);
    if (project == null) {
        task.run(new EmptyProgressIndicator());
    } else {
        ProgressManager.getInstance().run(task);
    }
    return true;
}
Also used : EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) LogMessageEx(com.intellij.diagnostic.LogMessageEx) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) Consumer(com.intellij.util.Consumer) ErrorBean(com.intellij.errorreport.bean.ErrorBean) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo)

Example 2 with ErrorBean

use of com.intellij.errorreport.bean.ErrorBean in project intellij-elixir by KronicDeth.

the class Submitter method errorBean.

@NotNull
private static ErrorBean errorBean(@NotNull IdeaLoggingEvent[] events, String additionalInfo) {
    IdeaLoggingEvent event = events[0];
    ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
    bean.setDescription(additionalInfo);
    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(includedAttachments((LogMessageEx) data));
    }
    return bean;
}
Also used : ErrorBean(com.intellij.errorreport.bean.ErrorBean) LogMessageEx(com.intellij.diagnostic.LogMessageEx) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ErrorBean

use of com.intellij.errorreport.bean.ErrorBean in project intellij-elixir by KronicDeth.

the class Submitter method submit.

/**
     * This method is called whenever an exception in a plugin code had happened and a user decided to report a problem
     * to the plugin vendor.
     *
     * @param events          a non-empty sequence of error descriptors.
     * @param additionalInfo  additional information provided by a user.
     * @param parentComponent UI component to use as a parent in any UI activity from a submitter.
     * @param consumer        a callback to be called after sending is finished (or failed).
     * @return {@code true} if reporting was started, {@code false} if a report can't be sent at the moment.
     */
@Override
public boolean submit(@NotNull IdeaLoggingEvent[] events, String additionalInfo, @NotNull Component parentComponent, @NotNull final Consumer<SubmittedReportInfo> consumer) {
    final Project project = project(parentComponent);
    ErrorBean errorBean = errorBean(events, additionalInfo);
    Consumer<Boolean> successCallback = successCallback(project, consumer);
    Consumer<Exception> errorCallback = errorCallback(project);
    Task task = new Task(project, errorBean, successCallback, errorCallback);
    run(task, project == null);
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) ErrorBean(com.intellij.errorreport.bean.ErrorBean) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with ErrorBean

use of com.intellij.errorreport.bean.ErrorBean in project android by JetBrains.

the class ErrorReporter method submit.

@Override
public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String description, @Nullable Component parentComponent, @NotNull Consumer<SubmittedReportInfo> callback) {
    IdeaLoggingEvent event = events[0];
    ErrorBean bean = new ErrorBean(event.getThrowable(), IdeaLogger.ourLastActionId);
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    bean.setDescription(description);
    bean.setMessage(event.getMessage());
    Throwable t = event.getThrowable();
    if (t != null) {
        final PluginId pluginId = IdeErrorsDialog.findPluginId(t);
        if (pluginId != null) {
            final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(pluginId);
            if (ideaPluginDescriptor != null && (!ideaPluginDescriptor.isBundled() || ideaPluginDescriptor.allowBundledUpdate())) {
                bean.setPluginName(ideaPluginDescriptor.getName());
                bean.setPluginVersion(ideaPluginDescriptor.getVersion());
            }
        }
    }
    Object data = event.getData();
    // Early escape (and no UI impact) if these are analytics events being pushed from the platform
    if (handleAnalyticsReports(t, data)) {
        return true;
    }
    if (data instanceof AbstractMessage) {
        bean.setAttachments(((AbstractMessage) data).getIncludedAttachments());
    }
    final Project project = CommonDataKeys.PROJECT.getData(dataContext);
    Consumer<String> successCallback = 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 = e -> {
        String message = AndroidBundle.message("error.report.at.b.android", e.getMessage());
        ReportMessages.GROUP.createNotification(ReportMessages.ERROR_REPORT, message, NotificationType.ERROR, NotificationListener.URL_OPENING_LISTENER).setImportant(false).notify(project);
    };
    Task.Backgroundable feedbackTask;
    if (data instanceof ErrorReportCustomizer) {
        feedbackTask = ((ErrorReportCustomizer) data).makeReportingTask(project, FEEDBACK_TASK_TITLE, true, bean, successCallback, errorCallback);
    } else {
        List<Pair<String, String>> kv = IdeaITNProxy.getKeyValuePairs(null, null, bean, IdeaLogger.getOurCompilationTimestamp(), ApplicationManager.getApplication(), (ApplicationInfoEx) ApplicationInfo.getInstance(), ApplicationNamesInfo.getInstance(), UpdateSettings.getInstance());
        feedbackTask = new SubmitCrashReportTask(project, FEEDBACK_TASK_TITLE, true, t, pair2map(kv), successCallback, errorCallback);
    }
    if (project == null) {
        feedbackTask.run(new EmptyProgressIndicator());
    } else {
        ProgressManager.getInstance().run(feedbackTask);
    }
    return true;
}
Also used : SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo) DataContext(com.intellij.openapi.actionSystem.DataContext) IdeErrorsDialog(com.intellij.diagnostic.IdeErrorsDialog) ReportMessages(com.intellij.diagnostic.ReportMessages) Task(com.intellij.openapi.progress.Task) CrashReport(com.android.tools.idea.diagnostics.crash.CrashReport) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) Map(java.util.Map) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Project(com.intellij.openapi.project.Project) CommonDataKeys(com.intellij.openapi.actionSystem.CommonDataKeys) ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) ErrorReportSubmitter(com.intellij.openapi.diagnostic.ErrorReportSubmitter) DataManager(com.intellij.ide.DataManager) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginManager(com.intellij.ide.plugins.PluginManager) ProgressManager(com.intellij.openapi.progress.ProgressManager) AndroidBundle(org.jetbrains.android.util.AndroidBundle) IdeaLogger(com.intellij.idea.IdeaLogger) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Nullable(com.android.annotations.Nullable) Maps(com.google.common.collect.Maps) NotificationListener(com.intellij.notification.NotificationListener) NotificationType(com.intellij.notification.NotificationType) java.awt(java.awt) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) ErrorBean(com.intellij.errorreport.bean.ErrorBean) List(java.util.List) AbstractMessage(com.intellij.diagnostic.AbstractMessage) CrashReporter(com.android.tools.idea.diagnostics.crash.CrashReporter) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) Pair(com.intellij.openapi.util.Pair) ApplicationManager(com.intellij.openapi.application.ApplicationManager) IdeaITNProxy(org.jetbrains.android.diagnostics.error.IdeaITNProxy) NotNull(org.jetbrains.annotations.NotNull) PluginId(com.intellij.openapi.extensions.PluginId) Consumer(com.intellij.util.Consumer) Task(com.intellij.openapi.progress.Task) AbstractMessage(com.intellij.diagnostic.AbstractMessage) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) ErrorBean(com.intellij.errorreport.bean.ErrorBean) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo) Pair(com.intellij.openapi.util.Pair)

Aggregations

ErrorBean (com.intellij.errorreport.bean.ErrorBean)4 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)3 PluginId (com.intellij.openapi.extensions.PluginId)3 Project (com.intellij.openapi.project.Project)3 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 DataContext (com.intellij.openapi.actionSystem.DataContext)2 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)2 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)2 Consumer (com.intellij.util.Consumer)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (com.android.annotations.Nullable)1 CrashReport (com.android.tools.idea.diagnostics.crash.CrashReport)1 CrashReporter (com.android.tools.idea.diagnostics.crash.CrashReporter)1 Maps (com.google.common.collect.Maps)1 AbstractMessage (com.intellij.diagnostic.AbstractMessage)1 IdeErrorsDialog (com.intellij.diagnostic.IdeErrorsDialog)1 ReportMessages (com.intellij.diagnostic.ReportMessages)1 DataManager (com.intellij.ide.DataManager)1 PluginManager (com.intellij.ide.plugins.PluginManager)1