Skip to content

Commit 77aec2a

Browse files
ddamkeddamke
authored andcommitted
add try catch
1 parent 68b0269 commit 77aec2a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/java/de/doubleslash/keeptime/view/SettingsController.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,27 @@ private void initImportButton(){
247247
final FileChooser fileChooser = new FileChooser();
248248
fileChooser.setTitle("Open Exported SQl Script");
249249
File file = fileChooser.showOpenDialog(thisStage);
250-
250+
if (file == null) {
251+
LOG.info("User canceled import.");
252+
return;
253+
}
251254
LOG.info(file.toString());
252255

253256
final String url = applicationProperties.getSpringDataSourceUrl();
254257
final String username = applicationProperties.getSpringDataSourceUserName();
255258
final String password = applicationProperties.getSpringDataSourcePassword();
256-
;
257259
RunScript.execute(url, username, password, file.toString(), Charset.defaultCharset(), true);
258260

259261

260262
} catch (SQLException e) {
261-
throw new RuntimeException(e);
263+
LOG.error("Could not import script file to db.", e);
264+
265+
Alert errorDialog = new Alert(AlertType.ERROR);
266+
errorDialog.setTitle("Import failed");
267+
errorDialog.setHeaderText("The current data could not be imported.");
268+
errorDialog.setContentText("Please inform a developer and provide your log file.");
269+
270+
errorDialog.showAndWait();
262271
}
263272

264273
});

0 commit comments

Comments
 (0)