提交 0224468b 编写于 作者: A Alexey Milovidov

Save stack trace on exception from typeid_cast [#CLICKHOUSE-4].

上级 ed3c0125
......@@ -2,6 +2,18 @@
#include <type_traits>
#include <typeinfo>
#include <string>
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int BAD_CAST;
}
}
/** Проверяет совпадение типа путём сравнения typeid-ов.
......@@ -14,7 +26,8 @@ typename std::enable_if<std::is_reference<To>::value, To>::type typeid_cast(From
if (typeid(from) == typeid(To))
return static_cast<To>(from);
else
throw std::bad_cast();
throw DB::Exception("Bad cast from type " + std::string(typeid(from).name) + " to " + std::string(typeid(To).name),
DB::ErrorCodes::BAD_CAST);
}
template <typename To, typename From>
......
......@@ -370,6 +370,7 @@ namespace ErrorCodes
extern const int OUTPUT_IS_NOT_SORTED = 365;
extern const int SIZES_OF_NESTED_COLUMNS_ARE_INCONSISTENT = 366;
extern const int TOO_MUCH_FETCHES = 367;
extern const int BAD_CAST = 368;
extern const int KEEPER_EXCEPTION = 999;
extern const int POCO_EXCEPTION = 1000;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册