mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Provide more information about errors.
This commit is contained in:
parent
fb90e9d091
commit
8146093794
@ -525,6 +525,7 @@
|
||||
M(556, SYNC_MYSQL_USER_ACCESS_ERROR)\
|
||||
M(557, UNKNOWN_UNION) \
|
||||
M(558, EXPECTED_ALL_OR_DISTINCT) \
|
||||
M(559, INVALID_GRPC_QUERY_INFO) \
|
||||
\
|
||||
M(999, KEEPER_EXCEPTION) \
|
||||
M(1000, POCO_EXCEPTION) \
|
||||
|
@ -31,6 +31,7 @@ namespace DB
|
||||
{
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int INVALID_GRPC_QUERY_INFO;
|
||||
extern const int NETWORK_ERROR;
|
||||
extern const int NO_DATA_TO_INSERT;
|
||||
extern const int UNKNOWN_DATABASE;
|
||||
@ -267,6 +268,8 @@ namespace
|
||||
query_context->applySettingsChanges(settings_changes);
|
||||
const Settings & settings = query_context->getSettingsRef();
|
||||
|
||||
send_exception_with_stacktrace = query_context->getSettingsRef().calculate_text_stack_trace;
|
||||
|
||||
/// Set the current database if specified.
|
||||
if (!query_info.database().empty())
|
||||
{
|
||||
@ -371,6 +374,14 @@ namespace
|
||||
while (query_info.next_query_info())
|
||||
{
|
||||
readQueryInfo();
|
||||
if (!query_info.query().empty() || !query_info.query_id().empty() || query_info.settings_size()
|
||||
|| !query_info.database().empty() || !query_info.input_data_delimiter().empty() || !query_info.output_format().empty()
|
||||
|| !query_info.user_name().empty() || !query_info.password().empty() || !query_info.quota().empty())
|
||||
{
|
||||
throw Exception("Extra query infos can be used only to add more input data. "
|
||||
"Only the following fields can be set: input_data, next_query_info",
|
||||
ErrorCodes::INVALID_GRPC_QUERY_INFO);
|
||||
}
|
||||
if (!query_info.input_data().empty())
|
||||
{
|
||||
const char * begin = query_info.input_data().data();
|
||||
@ -479,6 +490,8 @@ namespace
|
||||
{
|
||||
io.onException();
|
||||
|
||||
LOG_ERROR(log, "Code: {}, e.displayText() = {}, Stack trace:\n\n{}", exception.code(), exception.displayText(), exception.getStackTraceString());
|
||||
|
||||
if (responder && !responder_finished)
|
||||
{
|
||||
try
|
||||
@ -626,7 +639,10 @@ namespace
|
||||
{
|
||||
auto & grpc_exception = *result.mutable_exception();
|
||||
grpc_exception.set_code(exception.code());
|
||||
grpc_exception.set_message(getExceptionMessage(exception, send_exception_with_stacktrace, true));
|
||||
grpc_exception.set_name(exception.name());
|
||||
grpc_exception.set_display_text(exception.displayText());
|
||||
if (send_exception_with_stacktrace)
|
||||
grpc_exception.set_stack_trace(exception.getStackTraceString());
|
||||
sendResult();
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,10 @@ message Progress {
|
||||
}
|
||||
|
||||
message Exception {
|
||||
int32 code = 1;
|
||||
string message = 2;
|
||||
int32 code = 1;
|
||||
string name = 2;
|
||||
string display_text = 3;
|
||||
string stack_trace = 4;
|
||||
}
|
||||
|
||||
message Result {
|
||||
|
@ -57,7 +57,7 @@ def query_common(query_text, settings={}, input_data=[], output_format='TabSepar
|
||||
def query_no_errors(*args, **kwargs):
|
||||
results = query_common(*args, **kwargs)
|
||||
if results and results[-1].HasField('exception'):
|
||||
raise Exception(results[-1].exception.message)
|
||||
raise Exception(results[-1].exception.display_text)
|
||||
return results
|
||||
|
||||
def query(*args, **kwargs):
|
||||
@ -131,7 +131,7 @@ def test_totals_and_extremes():
|
||||
def test_errors_handling():
|
||||
e = query_and_get_error("")
|
||||
#print(e)
|
||||
assert "Empty query" in e.message
|
||||
assert "Empty query" in e.display_text
|
||||
query("CREATE TABLE t (a UInt8) ENGINE = Memory")
|
||||
e = query_and_get_error("CREATE TABLE t (a UInt8) ENGINE = Memory")
|
||||
assert "Table default.t already exists" in e.message
|
||||
assert "Table default.t already exists" in e.display_text
|
||||
|
Loading…
Reference in New Issue
Block a user