added errorhandler

This commit is contained in:
potzplitz 2024-09-08 14:57:19 +02:00
parent 8ff5e2947e
commit bf1195bb49
6 changed files with 68 additions and 0 deletions

10
pom.xml
View file

@ -52,6 +52,16 @@
<artifactId>github-api</artifactId>
<version>1.127</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
<dependency>
<groupId>io.qtjambi</groupId>
<artifactId>qtjambi</artifactId>

View file

@ -83,6 +83,7 @@ public class DownloadLevels {
fileOutputStream.write(dataBuffer, 0, bytesRead);
}
} catch (IOException e) {
e.printStackTrace();
}

View file

@ -0,0 +1,21 @@
package errorhandler;
import java.io.PrintWriter;
import java.io.StringWriter;
import javax.swing.JOptionPane;
public class ErrorHandler {
public void newError(Throwable e) {
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
JOptionPane.showMessageDialog(null, sw.toString() + "", e.getMessage(), JOptionPane.ERROR_MESSAGE);
System.exit(-1);
}
}

View file

@ -0,0 +1,18 @@
package errorhandler;
import java.util.Properties;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
public class ErrorSubmission {
}

View file

@ -3,11 +3,14 @@ package main;
import java.io.IOException;
import java.util.zip.DataFormatException;
import javax.swing.JOptionPane;
import api.GetApiData;
import data.FetchData;
import data.ManageFiles;
import database.DatabaseManager;
import database.Sqlite;
import errorhandler.ErrorHandler;
import filestructure.CreateFileStructure;
import gui.LoadMenu;
import preload.PreChecks;
@ -16,6 +19,16 @@ import settingsfunctions.LoadSettings;
public class Main {
public static void main(String[] args) throws IOException, DataFormatException {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
ErrorHandler error = new ErrorHandler();
error.newError(e);
}
});
try {
LoadMenu load = new LoadMenu();
load.onLoad();
@ -54,6 +67,10 @@ public class Main {
load.updateBar("Ladevorgang abgeschlossen");
load.close();
} catch (Exception e) {
System.out.println("fehler");
}
}
}

View file

@ -10,4 +10,5 @@
requires java.xml;
requires org.apache.commons.codec;
requires github.api;
requires java.mail;
}