diff --git a/dune/stuff/common/configuration.hh b/dune/stuff/common/configuration.hh index 26515449933b120363980787e3ee5786863d0364..16457e46496aa6c39e9f00eec910f8c18ba2854a 100644 --- a/dune/stuff/common/configuration.hh +++ b/dune/stuff/common/configuration.hh @@ -525,13 +525,22 @@ private: const size_t size, const size_t cols) const { std::string valstring = BaseType::get(key, toString(def)); - T val = fromString<T>(valstring, size, cols); - if (validator(val)) - return val; - else { - std::stringstream ss; - validator.print(ss); - DUNE_THROW(Exceptions::configuration_error, ss.str()); + try { + T val = fromString<T>(valstring, size, cols); + if (validator(val)) + return val; + else + DUNE_THROW(Exceptions::configuration_error, validator.msg()); + } catch (boost::bad_lexical_cast& e) { + DUNE_THROW(Exceptions::external_error, + "Error in boost while converting the string '" << valstring << "' to type '" << Typename<T>::value() + << "':\n" + << e.what()); + } catch (std::exception& e) { + DUNE_THROW(Exceptions::external_error, + "Error in the stl while converting the string '" << valstring << "' to type '" << Typename<T>::value() + << "':\n" + << e.what()); } } // ... get_valid_value(...)