Skip to content

Commit

Permalink
fix: the problem of inconsistent error message returned when auto_cre…
Browse files Browse the repository at this point in the history
…ate_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.
  • Loading branch information
chunshao90 authored May 31, 2023
1 parent ae44390 commit 32d3d36
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions proxy/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions proxy/src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ impl<Q: QueryExecutor + 'static> Proxy<Q> {

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",
Expand Down

0 comments on commit 32d3d36

Please sign in to comment.