diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index d4f72ffb3..f3561d60b 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -9,6 +9,7 @@ #include "3mf.hpp" #include +#include #include #include @@ -102,6 +103,13 @@ const char* INVALID_OBJECT_TYPES[] = "other" }; +class version_error : public std::runtime_error +{ +public: + version_error(const std::string& what_arg) : std::runtime_error(what_arg) {} + version_error(const char* what_arg) : std::runtime_error(what_arg) {} +}; + const char* get_attribute_value_charptr(const char** attributes, unsigned int attributes_size, const char* attribute_key) { if ((attributes == nullptr) || (attributes_size == 0) || (attributes_size % 2 != 0) || (attribute_key == nullptr)) @@ -731,6 +739,11 @@ namespace Slic3r { return n; }, &data, 0); } + catch (const version_error& e) + { + // rethrow the exception + throw std::runtime_error(e.what()); + } catch (std::exception& e) { add_error(e.what()); @@ -1440,7 +1453,7 @@ namespace Slic3r { if (m_check_version && (m_version > VERSION_3MF)) { std::string msg = _(L("The selected 3mf file has been saved with a newer version of " + std::string(SLIC3R_APP_NAME) + " and is not compatibile.")); - throw std::runtime_error(msg.c_str()); + throw version_error(msg.c_str()); } }