FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
Pane pane = loader.load();
AlertWindowController controller = loader.getController();
setup.accept(dialogStage, controller);
dialogStage.setScene(new Scene(pane));
dialogStage.showAndWait();
} catch (Throwable e) {
// We crashed whilst trying to show the alert dialog. This can happen if we're being crashed by inbound
// closures onto the event thread which will execute in the nested event loop. Just give up here: at the
// moment we have no way to filter them out of the event queue.
e.printStackTrace();