summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
Diffstat (limited to 'bench')
-rw-r--r--bench/bench_window.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/bench/bench_window.cpp b/bench/bench_window.cpp
index d872de7..767198b 100644
--- a/bench/bench_window.cpp
+++ b/bench/bench_window.cpp
@@ -223,22 +223,19 @@ void bench_window::on_add_warrior_dialog_response(int response_id, Gtk::FileChoo
gsize length;
file->load_contents(contents, length);
- auto w = lib94::compile_warrior(std::string(contents, length));
-
- delete contents;
-
- if (std::holds_alternative<lib94::warrior *>(w)) {
- warriors.push_back(std::get<lib94::warrior *>(w));
+ try {
+ warriors.push_back(lib94::compile_warrior(std::string(contents, length)));
on_click_new_round();
}
-
- else {
- Gtk::MessageDialog *md = new Gtk::MessageDialog(std::string("Failed to compile: ") + std::get<std::string>(w));
+ catch (const lib94::compiler_exception &ex) {
+ Gtk::MessageDialog *md = new Gtk::MessageDialog(std::string("failed to compile: ") + ex.message + " on line " + std::to_string(ex.line_number));
md->set_transient_for(*this);
md->set_modal();
md->signal_response().connect([md](int) {delete md;});
md->show();
}
+
+ delete contents;
}
delete dialog;