|
@@ -23,7 +23,6 @@
|
23
|
23
|
package com.dmdirc.logger;
|
24
|
24
|
|
25
|
25
|
import com.dmdirc.util.ClientInfo;
|
26
|
|
-import com.dmdirc.util.io.Downloader;
|
27
|
26
|
|
28
|
27
|
import java.io.File;
|
29
|
28
|
import java.io.FileOutputStream;
|
|
@@ -31,15 +30,9 @@ import java.io.IOException;
|
31
|
30
|
import java.io.OutputStream;
|
32
|
31
|
import java.io.PrintWriter;
|
33
|
32
|
import java.io.Serializable;
|
34
|
|
-import java.net.MalformedURLException;
|
35
|
33
|
import java.text.DateFormat;
|
36
|
34
|
import java.text.SimpleDateFormat;
|
37
|
|
-import java.util.ArrayList;
|
38
|
|
-import java.util.Arrays;
|
39
|
35
|
import java.util.Date;
|
40
|
|
-import java.util.HashMap;
|
41
|
|
-import java.util.List;
|
42
|
|
-import java.util.Map;
|
43
|
36
|
import java.util.Objects;
|
44
|
37
|
import java.util.concurrent.Semaphore;
|
45
|
38
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
@@ -311,11 +304,8 @@ public final class ProgramError implements Serializable {
|
311
|
304
|
* Sends this error report to the DMDirc developers.
|
312
|
305
|
*/
|
313
|
306
|
public void send() {
|
314
|
|
- sendToSentry();
|
315
|
|
- sendToLegacy();
|
316
|
|
- }
|
|
307
|
+ setReportStatus(ErrorReportStatus.SENDING);
|
317
|
308
|
|
318
|
|
- private void sendToSentry() {
|
319
|
309
|
final Raven raven = RavenFactory.ravenInstance(new Dsn(SENTRY_DSN));
|
320
|
310
|
|
321
|
311
|
// record a simple message
|
|
@@ -345,78 +335,9 @@ public final class ProgramError implements Serializable {
|
345
|
335
|
}
|
346
|
336
|
|
347
|
337
|
raven.sendEvent(eventBuilder.build());
|
348
|
|
- }
|
349
|
|
-
|
350
|
|
- private void sendToLegacy() {
|
351
|
|
- final Map<String, String> postData = new HashMap<>();
|
352
|
|
- List<String> response = new ArrayList<>();
|
353
|
|
- int tries = 0;
|
354
|
|
-
|
355
|
|
- String traceString = Arrays.toString(getTrace());
|
356
|
|
- if (traceString.isEmpty() || traceString.equals("[]")) {
|
357
|
|
- traceString = "[No Trace]";
|
358
|
|
- }
|
359
|
|
- postData.put("message", getMessage());
|
360
|
|
- postData.put("trace", traceString);
|
361
|
|
- postData.put("version", ClientInfo.getVersion());
|
362
|
|
-
|
363
|
|
- setReportStatus(ErrorReportStatus.SENDING);
|
364
|
|
-
|
365
|
|
- do {
|
366
|
|
- if (tries != 0) {
|
367
|
|
- try {
|
368
|
|
- Thread.sleep(5000);
|
369
|
|
- } catch (InterruptedException ex) {
|
370
|
|
- //Ignore
|
371
|
|
- }
|
372
|
|
- }
|
373
|
|
- try {
|
374
|
|
- response = Downloader.getPage("http://www.dmdirc.com/error.php", postData);
|
375
|
|
- } catch (MalformedURLException ex) {
|
376
|
|
- //Ignore, wont happen
|
377
|
|
- } catch (IOException ex) {
|
378
|
|
- //Ignore being handled
|
379
|
|
- }
|
380
|
|
-
|
381
|
|
- tries++;
|
382
|
|
- } while ((response.isEmpty() || !response.get(response.size() - 1).
|
383
|
|
- equalsIgnoreCase("Error report submitted. Thank you."))
|
384
|
|
- && tries <= 5);
|
385
|
338
|
|
386
|
|
- checkResponses(response);
|
387
|
|
- }
|
388
|
|
-
|
389
|
|
- /**
|
390
|
|
- * Checks the responses and sets status accordingly.
|
391
|
|
- *
|
392
|
|
- * @param response Response to check
|
393
|
|
- */
|
394
|
|
- private void checkResponses(final List<String> response) {
|
395
|
|
- if (!response.isEmpty() && response.get(response.size() - 1).
|
396
|
|
- equalsIgnoreCase("Error report submitted. Thank you.")) {
|
397
|
|
- setReportStatus(ErrorReportStatus.FINISHED);
|
398
|
|
- } else {
|
399
|
|
- setReportStatus(ErrorReportStatus.ERROR);
|
400
|
|
- return;
|
401
|
|
- }
|
402
|
|
-
|
403
|
|
- if (response.size() == 1) {
|
404
|
|
- setFixedStatus(ErrorFixedStatus.NEW);
|
405
|
|
- return;
|
406
|
|
- }
|
407
|
|
-
|
408
|
|
- final String responseToCheck = response.get(0);
|
409
|
|
- if (responseToCheck.matches(".*fixed.*")) {
|
410
|
|
- setFixedStatus(ErrorFixedStatus.FIXED);
|
411
|
|
- } else if (responseToCheck.matches(".*more recent version.*")) {
|
412
|
|
- setFixedStatus(ErrorFixedStatus.TOOOLD);
|
413
|
|
- } else if (responseToCheck.matches(".*invalid.*")) {
|
414
|
|
- setFixedStatus(ErrorFixedStatus.INVALID);
|
415
|
|
- } else if (responseToCheck.matches(".*previously.*")) {
|
416
|
|
- setFixedStatus(ErrorFixedStatus.KNOWN);
|
417
|
|
- } else {
|
418
|
|
- setFixedStatus(ErrorFixedStatus.NEW);
|
419
|
|
- }
|
|
339
|
+ setReportStatus(ErrorReportStatus.FINISHED);
|
|
340
|
+ setFixedStatus(ErrorFixedStatus.NEW);
|
420
|
341
|
}
|
421
|
342
|
|
422
|
343
|
/**
|