From 7ee2e68f5b85e96ad31b4b5fbcf887432b93e240 Mon Sep 17 00:00:00 2001 From: Alexander Kuzmenkov Date: Thu, 25 Jun 2020 23:23:56 +0300 Subject: [PATCH] better error messages --- src/Functions/array/arrayElement.cpp | 12 ++++++++++-- src/Functions/finalizeAggregation.cpp | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Functions/array/arrayElement.cpp b/src/Functions/array/arrayElement.cpp index 6113a16ddfa..0ec84621953 100644 --- a/src/Functions/array/arrayElement.cpp +++ b/src/Functions/array/arrayElement.cpp @@ -732,10 +732,18 @@ DataTypePtr FunctionArrayElement::getReturnTypeImpl(const DataTypes & arguments) { const DataTypeArray * array_type = checkAndGetDataType(arguments[0].get()); 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])) - 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(); } diff --git a/src/Functions/finalizeAggregation.cpp b/src/Functions/finalizeAggregation.cpp index 522a645b8e7..e16870c80ec 100644 --- a/src/Functions/finalizeAggregation.cpp +++ b/src/Functions/finalizeAggregation.cpp @@ -49,8 +49,11 @@ public: { const DataTypeAggregateFunction * type = checkAndGetDataType(arguments[0].get()); 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(); }