Search in sources :

Example 1 with LogMessageEx

use of com.intellij.diagnostic.LogMessageEx 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 LogMessageEx

use of com.intellij.diagnostic.LogMessageEx 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 LogMessageEx

use of com.intellij.diagnostic.LogMessageEx in project intellij-elixir by KronicDeth.

the class Submitter method includedAttachments.

/**
     * Gets the attachment the user has marked to be included.  Tries to use
     * {@link LogMessageEx#getIncludedAttachments()}, and then {@link LogMessageEx#getAttachments()}.
     *
     * @param logMessageEx with attachments
     * @return the attachments
     */
private static List<Attachment> includedAttachments(LogMessageEx logMessageEx) {
    Class<LogMessageEx> klass = LogMessageEx.class;
    List<Attachment> attachmentList = Collections.emptyList();
    try {
        Method getIncludedAttachments = klass.getDeclaredMethod("getIncludedAttachments", LogMessageEx.class);
        try {
            attachmentList = (List<Attachment>) getIncludedAttachments.invoke(logMessageEx);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    } catch (NoSuchMethodException noSuchGetIncludedAttachmentsMethod) {
        try {
            Method getAttachments = klass.getDeclaredMethod("getAttachments", LogMessageEx.class);
            try {
                attachmentList = (List<Attachment>) getAttachments.invoke(logMessageEx);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        } catch (NoSuchMethodException noSuchGetAttachmentsMethod) {
            noSuchGetAttachmentsMethod.printStackTrace();
        }
    }
    return attachmentList;
}
Also used : LogMessageEx(com.intellij.diagnostic.LogMessageEx) Attachment(com.intellij.openapi.diagnostic.Attachment) List(java.util.List) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

LogMessageEx (com.intellij.diagnostic.LogMessageEx)3 ErrorBean (com.intellij.errorreport.bean.ErrorBean)2 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)2 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)2 PluginId (com.intellij.openapi.extensions.PluginId)2 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Attachment (com.intellij.openapi.diagnostic.Attachment)1 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)1 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 Consumer (com.intellij.util.Consumer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1