Improve error message for failed casts

refs #6070
This commit is contained in:
Gunnar Beutner 2015-01-29 16:51:47 +01:00
parent d713a6c940
commit e0be9cd743
1 changed files with 7 additions and 1 deletions

View File

@ -42,7 +42,13 @@ Value::operator double(void) const
if (IsEmpty()) if (IsEmpty())
return 0; return 0;
return boost::lexical_cast<double>(m_Value); try {
return boost::lexical_cast<double>(m_Value);
} catch (const std::exception&) {
std::ostringstream msgbuf;
msgbuf << "Can't convert '" << *this << "' to a floating point number.";
BOOST_THROW_EXCEPTION(std::invalid_argument(msgbuf.str()));
}
} }
Value::operator String(void) const Value::operator String(void) const