use of com.intellij.openapi.diagnostic.IdeaLoggingEvent 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.openapi.diagnostic.IdeaLoggingEvent in project intellij-community by JetBrains.
the class DropAnErrorWithAttachmentsAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final boolean multipleAttachments = (e.getModifiers() & InputEvent.SHIFT_MASK) != 0;
Attachment[] attachments;
if (multipleAttachments) {
attachments = new Attachment[] { new Attachment("first.txt", "first content"), new Attachment("second.txt", "second content") };
} else {
attachments = new Attachment[] { new Attachment("attachment.txt", "content") };
}
IdeaLoggingEvent test = LogMessageEx.createEvent("test", "test details", attachments);
throw new LogEventException(test);
//Logger.getInstance("test (with attachments)").error(test);
}
use of com.intellij.openapi.diagnostic.IdeaLoggingEvent in project Perl5-IDEA by Camelcade.
the class YoutrackErrorHandler method doSubmit.
private SubmittedReportInfo doSubmit(IdeaLoggingEvent[] ideaLoggingEvents, String addInfo, Component component) {
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(SystemInfo.JAVA_VENDOR).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
}
if (ResultString == null) {
return new SubmittedReportInfo(SERVER_ISSUE_URL, "", FAILED);
}
final SubmittedReportInfo reportInfo = new SubmittedReportInfo(SERVER_URL + "issue/" + ResultString, ResultString, NEW_ISSUE);
if (signature != 0) {
runCommand(ResultString, "Exception Signature " + signature);
}
popupResultInfo(reportInfo, project);
return reportInfo;
}
use of com.intellij.openapi.diagnostic.IdeaLoggingEvent in project flutter-intellij by flutter.
the class FlutterErrorReportSubmitter method submitAsync.
@SuppressWarnings("deprecation")
@Override
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 PluginId pid = FlutterUtils.getPluginId();
final IdeaPluginDescriptor flutterPlugin = PluginManager.getPlugin(pid);
// noinspection ConstantConditions
builder.append(" • Flutter plugin `").append(pid.getIdString()).append(' ').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));
}
use of com.intellij.openapi.diagnostic.IdeaLoggingEvent 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;
}
Aggregations