OSDN Git Service

fix: use crash handler instead of outputing logs
authorhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Wed, 9 Mar 2022 05:04:37 +0000 (14:04 +0900)
committerhizumiaoba <56146205+hizumiaoba@users.noreply.github.com>
Wed, 9 Mar 2022 05:04:37 +0000 (14:04 +0900)
src/com/ranfa/lib/handler/CrashHandler.java
src/com/ranfa/lib/handler/CrashReportList.java

index 90f52c4..db2f096 100644 (file)
@@ -68,6 +68,7 @@ public class CrashHandler {
                                throw new NullPointerException("Cannot execute crash because throwable is null.");
                        LOG.error("Cannot keep up application! : {}", e.toString());
                        LOG.error(outputReport());
+                       crashReportLines.outCrashReport();
                        System.exit(estimateExitCode);
                }
                
index 5f9e1e0..8804250 100644 (file)
@@ -36,18 +36,20 @@ public class CrashReportList <E> extends ArrayList<E> {
                                str = (E) "\n";
                        builder.append(str).append("\n");
                }
+               return builder.toString();
+       }
+       @SuppressWarnings("unchecked")
+       public boolean emptyLine() {
+               return store.add((E) EMPTY_LINE_PLACEHOLDER);
+       }
+       
+       public void outCrashReport() {
                try {
                        FileWriter writer = new FileWriter(Paths.get("Crash-Report/" + FORMAT.format(new Date()) + ".txt").toFile());
-                       writer.write(builder.toString());
+                       writer.write(generateCrashReport());
                        writer.close();
                } catch (IOException e) {
                        LoggerFactory.getLogger(CrashReportList.class).error("Cannot write crash report.", e);
                }
-               return builder.toString();
-       }
-       
-       @SuppressWarnings("unchecked")
-       public boolean emptyLine() {
-               return store.add((E) EMPTY_LINE_PLACEHOLDER);
        }
 }