From 32d3d366ee3137a00a9a249b99e064540bbbd402 Mon Sep 17 00:00:00 2001 From: "chunshao.rcs" Date: Wed, 31 May 2023 14:37:28 +0800 Subject: [PATCH] fix: the problem of inconsistent error message returned when auto_create_table fails (#942) ## Related Issues Closes # ## Detailed Changes * Fix the problem of inconsistent error message returned when auto_create_table fails. * Grpc returns more detailed error info. ## Test Plan Manual test and CI. --- proxy/src/error.rs | 5 ++--- proxy/src/write.rs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/proxy/src/error.rs b/proxy/src/error.rs index 831e910adb..a54dca3374 100644 --- a/proxy/src/error.rs +++ b/proxy/src/error.rs @@ -43,14 +43,13 @@ impl Error { /// Get the error message returned to the user. pub fn error_message(&self) -> String { match self { - Error::ErrNoCause { msg, .. } => msg.clone(), + Error::ErrNoCause { msg, .. } | Error::InternalNoCause { msg, .. } => msg.clone(), - Error::ErrWithCause { msg, source, .. } => { + Error::ErrWithCause { msg, source, .. } | Error::Internal { msg, source, .. } => { let err_string = source.to_string(); let first_line = error_util::remove_backtrace_from_err(&err_string); format!("{msg}. Caused by: {first_line}") } - Error::Internal { msg, .. } | Error::InternalNoCause { msg, .. } => msg.clone(), } } } diff --git a/proxy/src/write.rs b/proxy/src/write.rs index fc5627e00e..8cb2b2f12a 100644 --- a/proxy/src/write.rs +++ b/proxy/src/write.rs @@ -279,10 +279,10 @@ impl Proxy { let output = self .execute_plan(request_id, catalog, schema, plan, deadline) - .await; + .await?; ensure!( - matches!(output, Ok(Output::AffectedRows(_))), + matches!(output, Output::AffectedRows(_)), ErrNoCause { code: StatusCode::INTERNAL_SERVER_ERROR, msg: "Invalid output type, expect AffectedRows, found Records",