Skip to content

Commit

Permalink
Merge pull request #318 from Haehnchen/feature/silent-submit
Browse files Browse the repository at this point in the history
submit error with final success feedback
  • Loading branch information
Haehnchen authored Oct 16, 2024
2 parents 21c002d + aae240e commit 58dce41
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.util.Consumer;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.entity.StringEntity;
Expand Down Expand Up @@ -88,8 +86,6 @@ public void run(@NotNull ProgressIndicator indicator) {
ApplicationManager.getApplication().invokeLater(() -> {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();


boolean success = false;
try {
ArrayList<NameValuePair> nameValuePairs = new ArrayList<>() {{
add(new BasicNameValuePair("plugin", pluginId));
Expand All @@ -100,20 +96,11 @@ public void run(@NotNull ProgressIndicator indicator) {
request.addHeader("x-plugin-version", pluginVersion);

request.setEntity(new StringEntity(s));
CloseableHttpResponse execute = httpClient.execute(request);
httpClient.execute(request);
httpClient.close();

int statusCode = execute.getStatusLine().getStatusCode();
success = statusCode >= 200 && statusCode < 300;
} catch (Exception ignored) {
}

if (!success) {
Messages.showErrorDialog(parentComponent, "Failed submitting your report!", "Error Report");
return;
}

Messages.showInfoMessage(parentComponent, "Thank you for submitting your report!", "Error Report");
consumer.consume(new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.NEW_ISSUE));
});
}
Expand Down

0 comments on commit 58dce41

Please sign in to comment.