Skip to content

Commit f2baf3d

Browse files
authored
Merge pull request #199 from openjavaformat/abashev/Report-for-exceptions
Send the IDE plugin's errors to the JetBrains Marketplace
2 parents 44e282b + 0e8164c commit f2baf3d

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎open-java-format-idea-plugin/src/main/java/com/palantir/javaformat/intellij/PalantirJavaFormatFormattingService.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ public void run() {
150150
request.onTextReady(formattedText);
151151
}
152152
} catch (FormatterException e) {
153-
logger.error(
153+
// A syntax error in the file, not a fault of the plugin: an error would go to its error reports.
154+
logger.warn(
154155
String.format(
155156
"Failed to format file %s",
156157
request.getContext().getContainingFile().getName()),
@@ -163,8 +164,9 @@ public void run() {
163164
throw e;
164165
} catch (RuntimeException e) {
165166
// Typically the formatter's JVM failing to start or exiting with an error. Left alone, the IDE
166-
// swallows it and Reformat looks as if it did nothing.
167-
logger.warn("open-java-format could not run the formatter", e);
167+
// swallows it and Reformat looks as if it did nothing. An error rather than a warning, so that it goes
168+
// to the plugin's error reports on the JetBrains Marketplace (see errorHandler in plugin.xml).
169+
logger.error("open-java-format could not run the formatter", e);
168170
request.onError(
169171
Notifications.GENERIC_ERROR_NOTIFICATION_GROUP,
170172
Notifications.formatterFailedMessage(

‎open-java-format-idea-plugin/src/main/resources/META-INF/plugin.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
<notificationGroup displayType="BALLOON" id="open-java-format parsing error"
3434
isLogByDefault="false"/>
3535
<notificationGroup displayType="STICKY_BALLOON" id="open-java-format native binary"/>
36+
<!-- Errors the IDE traces to this plugin go to the Exceptions tab of its JetBrains Marketplace page. A release
37+
IDE does not show them, as it does not show its own: the submitter is an ITNReporter, whose errors and
38+
Report button only EAP builds show. From a release IDE a report goes only when the user lets the IDE send
39+
error reports automatically, which 2024.2 cannot do. -->
40+
<errorHandler implementation="com.intellij.diagnostic.JetBrainsMarketplaceErrorReportSubmitter"/>
3641
</extensions>
3742

3843
</idea-plugin>

0 commit comments

Comments
 (0)