Better exception message

This commit is contained in:
Alexey Milovidov 2020-06-14 04:07:47 +03:00
parent 970a8e3ecc
commit 6c278fee61
2 changed files with 22 additions and 2 deletions

View File

@ -7,6 +7,8 @@
*/
#include <Common/SettingsChanges.h>
#include <Common/FieldVisitors.h>
namespace DB
{
@ -91,7 +93,16 @@ Field SettingsCollection<Derived>::const_reference::getValue() const
template <class Derived>
Field SettingsCollection<Derived>::valueToCorrespondingType(size_t index, const Field & value)
{
return members()[index].value_to_corresponding_type(value);
try
{
return members()[index].value_to_corresponding_type(value);
}
catch (Exception & e)
{
e.addMessage(fmt::format("in attempt to set the value of setting to {}",
applyVisitor(FieldVisitorToString(), value)));
throw;
}
}

View File

@ -982,7 +982,16 @@ void Context::setSetting(const StringRef & name, const Field & value)
void Context::applySettingChange(const SettingChange & change)
{
setSetting(change.name, change.value);
try
{
setSetting(change.name, change.value);
}
catch (Exception & e)
{
e.addMessage(fmt::format("in attempt to set the value of setting '{}' to {}",
change.name, applyVisitor(FieldVisitorToString(), change.value)));
throw;
}
}