From 8b7f0c53594241bb2af062ada3d62575c51b9c80 Mon Sep 17 00:00:00 2001 From: Vojtech Kral Date: Mon, 26 Aug 2019 17:17:23 +0200 Subject: [PATCH] Refactor a few more `catch(...)` instances --- src/avrdude/avrdude-slic3r.cpp | 12 ------------ src/slic3r/GUI/GUI_App.cpp | 5 +---- src/slic3r/Utils/Serial.cpp | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/avrdude/avrdude-slic3r.cpp b/src/avrdude/avrdude-slic3r.cpp index 7eff436e2e..b561cd8433 100644 --- a/src/avrdude/avrdude-slic3r.cpp +++ b/src/avrdude/avrdude-slic3r.cpp @@ -204,18 +204,6 @@ AvrDude::Ptr AvrDude::run() message_fn("\n", 1); } - if (self->p->complete_fn) { - self->p->complete_fn(); - } - } catch (...) { - self->p->exit_code = EXIT_EXCEPTION; - - static const char *msg = "An unkown exception was thrown in the background thread.\n"; - - if (self->p->message_fn) { - self->p->message_fn(msg, sizeof(msg)); - } - if (self->p->complete_fn) { self->p->complete_fn(); } diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 9fe0bab963..2b63447832 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -139,9 +139,6 @@ static void generic_exception_handle() wxLogError("Internal error: %s", ex.what()); BOOST_LOG_TRIVIAL(error) << boost::format("Uncaught exception: %1%") % ex.what(); throw; - } catch (...) { - wxLogError("Unknown internal error"); - BOOST_LOG_TRIVIAL(error) << "Uncaught exception: Unknown error"; } } @@ -169,7 +166,7 @@ bool GUI_App::OnInit() { try { return on_init_inner(); - } catch (...) { + } catch (const std::exception&) { generic_exception_handle(); return false; } diff --git a/src/slic3r/Utils/Serial.cpp b/src/slic3r/Utils/Serial.cpp index 5944646926..737e76c0b5 100644 --- a/src/slic3r/Utils/Serial.cpp +++ b/src/slic3r/Utils/Serial.cpp @@ -98,7 +98,7 @@ optional sysfs_tty_prop_hex(const std::string &tty_dev, const std if (!prop) { return boost::none; } try { return std::stoul(*prop, 0, 16); } - catch (...) { return boost::none; } + catch (const std::exception&) { return boost::none; } } #endif