[platform] handling for error submitters not implementing needed API (EA-248649)

GitOrigin-RevId: f8e418c8a0f653c51684badb5e5316613ff98477
This commit is contained in:
Roman Shevchenko
2020-12-11 20:25:56 +00:00
committed by intellij-monorepo-bot
parent 173850b897
commit 9ae1d16f4c
3 changed files with 22 additions and 26 deletions
@@ -65,6 +65,8 @@ public abstract class ErrorReportSubmitter implements PluginAware {
/**
* 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.
* <p>
* <b>Note</b>: the method is not abstract because compatibility, but all implementations must override it.
*
* @param events a non-empty sequence of error descriptors.
* @param additionalInfo additional information provided by a user.
@@ -76,33 +78,24 @@ public abstract class ErrorReportSubmitter implements PluginAware {
@Nullable String additionalInfo,
@NotNull Component parentComponent,
@NotNull Consumer<? super SubmittedReportInfo> consumer) {
return trySubmitAsync(events, additionalInfo, parentComponent, consumer);
try {
consumer.consume(submit(events, parentComponent));
return true;
}
catch (UnsupportedOperationException e) {
Logger.getInstance(getClass()).warn(e);
consumer.consume(new SubmittedReportInfo(null, e.getMessage(), SubmittedReportInfo.SubmissionStatus.FAILED));
return false;
}
}
//<editor-fold desc="Deprecated stuff.">
/** @deprecated do not override; implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} instead */
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2020.3")
@SuppressWarnings("ALL")
public boolean trySubmitAsync(IdeaLoggingEvent[] events, String info, Component parent, Consumer<? super SubmittedReportInfo> consumer) {
submitAsync(events, info, parent, consumer);
return true;
}
/** @deprecated do not override; implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} instead */
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2020.3")
@SuppressWarnings("ALL")
public void submitAsync(IdeaLoggingEvent[] events, String info, Component parent, Consumer<? super SubmittedReportInfo> consumer) {
consumer.consume(submit(events, parent));
}
/** @deprecated do not override; implement {@link #submit(IdeaLoggingEvent[], String, Component, Consumer)} instead */
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "2020.3")
@ApiStatus.ScheduledForRemoval(inVersion = "2021.3")
@SuppressWarnings("ALL")
public SubmittedReportInfo submit(IdeaLoggingEvent[] events, Component parent) {
throw new UnsupportedOperationException("Deprecated API called");
throw new UnsupportedOperationException("'" + getClass().getName() + "' doesn't implement exception submitter API");
}
//</editor-fold>
}
}
@@ -29,6 +29,7 @@ error.list.message.submitted=Submitted
error.list.message.submitted.as.link=Submitted as <a href="{0}">{1}</a>
error.list.message.duplicate=[Duplicate]
error.list.message.submission.failed=Submission failed
error.list.message.submission.failed.details=Submission failed ({0})
error.dialog.foreign.plugin.warning=This plugin is not a production of JetBrains. Please report the problem to <a href="{1}">{0}</a>.
error.dialog.foreign.plugin.warning.unnamed=This plugin is not a production of JetBrains. Please report the problem to the <a href="{0}">plugin vendor</a>.
error.dialog.foreign.plugin.warning.unknown=This plugin is not a production of JetBrains. Please report the problem to the plugin vendor.
@@ -467,14 +467,14 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
.append(DiagnosticBundle.message("error.list.disable.plugin")).append("</a>");
}
if (message.isSubmitted()) {
if (message.isSubmitting()) {
info.append(' ').append(DiagnosticBundle.message("error.list.message.submitting"));
}
else if (message.getSubmissionInfo() != null) {
info.append(' ').append("<span style=\"white-space: nowrap;\">");
appendSubmissionInformation(message.getSubmissionInfo(), info);
info.append("</span>");
}
else if (message.isSubmitting()) {
info.append(' ').append(DiagnosticBundle.message("error.list.message.submitting"));
}
myInfoLabel.setText(info.toString());
@@ -949,7 +949,9 @@ public class IdeErrorsDialog extends DialogWrapper implements MessagePoolListene
public static void appendSubmissionInformation(@NotNull SubmittedReportInfo info, @NotNull StringBuilder out) {
if (info.getStatus() == SubmittedReportInfo.SubmissionStatus.FAILED) {
out.append(DiagnosticBundle.message("error.list.message.submission.failed"));
String details = info.getLinkText();
out.append(details != null ? DiagnosticBundle.message("error.list.message.submission.failed.details", details)
: DiagnosticBundle.message("error.list.message.submission.failed"));
}
else if (info.getURL() != null && info.getLinkText() != null) {
out.append(DiagnosticBundle.message("error.list.message.submitted.as.link", info.getURL(), info.getLinkText()));