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;
}
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;
}
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;
}
Aggregations