Commit b9046a64 authored by Drahomír Karchňák's avatar Drahomír Karchňák

#781 Fixed NPE when using sentry logging on desktop version.

parent 0a80a0c7
......@@ -123,6 +123,8 @@ public class Tablexia extends TablexiaApplication {
private TablexiaComponentDialog errorDialog;
private TablexiaComponentDialog languageDialog;
private String sentryDSN;
public static class SQLConnectionType {
private String driver;
......@@ -150,14 +152,28 @@ public class Tablexia extends TablexiaApplication {
this.qrCodeScanner = qrCodeScanner;
this.sqlConnectionType = sqlConnectionType;
this.cameraOpener = cameraOpener;
this.sentryDSN = sentryDSN;
TablexiaSettings.init(buildType, systemLocale, hasSoftBackButton, supportAlternativeControls, hwSerial);
}
private void initializeBugReporting() {
if(TablexiaSettings.getInstance().getBuildType().isBugReport()) {
@SuppressWarnings("ConstantConditions")
String DSN = (TablexiaBuildConfig.SENTRY_DSN_FALLBACK == null || sentryDSN == null || TablexiaBuildConfig.SENTRY_DSN_FALLBACK.equals(sentryDSN)) ? null : sentryDSN;
TablexiaRaven.start(DSN);
// register error handler for exceptions in event bus handler methods
ApplicationBus.getInstance().addErrorHandler(new IPublicationErrorHandler() {
@Override
public void handleError(PublicationError error) {
Log.err(ApplicationBus.class, error.getMessage(), error.getCause());
TablexiaRaven.sendCustomException(TablexiaRaven.ExceptionType.JavaApplicationBusException, error.getMessage(), error.getCause());
}
});
}
}
private void initializeLogging() {
if(TablexiaSettings.getInstance().getBuildType().isLogFile()) {
try {
File file = new File(TablexiaAbstractFileManager.RootStorageType.LOCAL.getStoragePath(), LOG_FILE_NAME);
......@@ -171,15 +187,6 @@ public class Tablexia extends TablexiaApplication {
e.printStackTrace();
}
}
// register error handler for exceptions in event bus handler methods
ApplicationBus.getInstance().addErrorHandler(new IPublicationErrorHandler() {
@Override
public void handleError(PublicationError error) {
Log.err(ApplicationBus.class, error.getMessage(), error.getCause());
TablexiaRaven.sendCustomException(TablexiaRaven.ExceptionType.JavaApplicationBusException, error.getMessage(), error.getCause());
}
});
}
private void loadingComplete() {
......@@ -393,6 +400,10 @@ public class Tablexia extends TablexiaApplication {
public void create() {
super.create();
//TODO HERO
initializeBugReporting();
initializeLogging();
TablexiaRaven.sendSavedReports();
// init data storage
......
......@@ -199,7 +199,7 @@ public class TablexiaRaven {
public void storeRavenEvent(Event event) {
try {
String fileName = (HIDE_REPORT_FILES ? "" : "") + event.getId().toString() + REPORT_FILE_EXTENSION;
String fileName = (HIDE_REPORT_FILES ? "." : "") + event.getId().toString() + REPORT_FILE_EXTENSION;
File dir = TablexiaAbstractFileManager.getFileStoragePathFileHandle(ReportStorageType.EXTERNAL).file();
if(!dir.exists()) dir.mkdir();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment