better error messages

This commit is contained in:
Alexander Kuzmenkov 2020-06-25 23:23:56 +03:00
parent a8db0b40d0
commit 7ee2e68f5b
2 changed files with 15 additions and 4 deletions

View File

@ -732,10 +732,18 @@ DataTypePtr FunctionArrayElement::getReturnTypeImpl(const DataTypes & arguments)
{ {
const DataTypeArray * array_type = checkAndGetDataType<DataTypeArray>(arguments[0].get()); const DataTypeArray * array_type = checkAndGetDataType<DataTypeArray>(arguments[0].get());
if (!array_type) if (!array_type)
throw Exception("First argument for function " + getName() + " must be array.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); {
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"First argument for function '{}' must be array, got '{}' instead",
getName(), arguments[0]->getName());
}
if (!isInteger(arguments[1])) if (!isInteger(arguments[1]))
throw Exception("Second argument for function " + getName() + " must be integer.", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); {
throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Second argument for function '{}' must be integer, got '{}' instead",
getName(), arguments[1]->getName());
}
return array_type->getNestedType(); return array_type->getNestedType();
} }

View File

@ -49,8 +49,11 @@ public:
{ {
const DataTypeAggregateFunction * type = checkAndGetDataType<DataTypeAggregateFunction>(arguments[0].get()); const DataTypeAggregateFunction * type = checkAndGetDataType<DataTypeAggregateFunction>(arguments[0].get());
if (!type) if (!type)
throw Exception("Argument for function " + getName() + " must have type AggregateFunction - state of aggregate function.", {
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT,
"Argument for function '{}' must have type AggregateFunction - state of aggregate function."
" Got '{}' instead", getName(), arguments[0]->getName());
}
return type->getReturnType(); return type->getReturnType();
} }