From 3e22b39a42c911e18ac44e41c723b8699ed8fb87 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 7 Dec 2020 21:10:20 +0100 Subject: [PATCH] Improved error handling when loading invalid preset bundle. Improves Import Configuration bundle can fail if profile names have spaces at the end #5291 --- src/libslic3r/PresetBundle.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/PresetBundle.cpp b/src/libslic3r/PresetBundle.cpp index b020f874ed..f98abcc19f 100644 --- a/src/libslic3r/PresetBundle.cpp +++ b/src/libslic3r/PresetBundle.cpp @@ -1095,7 +1095,11 @@ size_t PresetBundle::load_configbundle(const std::string &path, unsigned int fla namespace pt = boost::property_tree; pt::ptree tree; boost::nowide::ifstream ifs(path); - pt::read_ini(ifs, tree); + try { + pt::read_ini(ifs, tree); + } catch (const boost::property_tree::ini_parser::ini_parser_error &err) { + throw Slic3r::RuntimeError(format("Failed loading config bundle \"%1%\"\nError: \"%2%\" at line %3%", path, err.message(), err.line()).c_str()); + } const VendorProfile *vendor_profile = nullptr; if (flags & (LOAD_CFGBNDLE_SYSTEM | LOAD_CFGBUNDLE_VENDOR_ONLY)) {