mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-17 13:30:38 +00:00
fix: print root cause error message to user facing interface (#2486)
This commit is contained in:
@@ -52,7 +52,7 @@ use futures::FutureExt;
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
use snafu::{ensure, ResultExt};
|
||||
use snafu::{ensure, ErrorCompat, ResultExt};
|
||||
use tokio::sync::oneshot::{self, Sender};
|
||||
use tokio::sync::Mutex;
|
||||
use tower::timeout::TimeoutLayer;
|
||||
@@ -315,7 +315,7 @@ impl JsonResponse {
|
||||
},
|
||||
Err(e) => {
|
||||
return Self::with_error(
|
||||
format!("Query engine output error: {e}"),
|
||||
e.iter_chain().last().unwrap().to_string(),
|
||||
e.status_code(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ use opensrv_mysql::{
|
||||
};
|
||||
use session::context::QueryContextRef;
|
||||
use snafu::prelude::*;
|
||||
use snafu::ErrorCompat;
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
use crate::error::{self, Error, OtherSnafu, Result};
|
||||
@@ -211,7 +212,8 @@ impl<'a, W: AsyncWrite + Unpin> MysqlResultWriter<'a, W> {
|
||||
);
|
||||
|
||||
let kind = ErrorKind::ER_INTERNAL_ERROR;
|
||||
w.error(kind, error.to_string().as_bytes()).await?;
|
||||
let error = error.iter_chain().last().unwrap().to_string();
|
||||
w.error(kind, error.as_bytes()).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ use pgwire::api::{ClientInfo, Type};
|
||||
use pgwire::error::{ErrorInfo, PgWireError, PgWireResult};
|
||||
use query::query_engine::DescribeResult;
|
||||
use session::Session;
|
||||
use snafu::ErrorCompat;
|
||||
use sql::dialect::PostgreSqlDialect;
|
||||
use sql::parser::ParserContext;
|
||||
|
||||
@@ -90,7 +91,7 @@ fn output_to_query_response<'a>(
|
||||
Err(e) => Ok(Response::Error(Box::new(ErrorInfo::new(
|
||||
"ERROR".to_string(),
|
||||
"XX000".to_string(),
|
||||
e.to_string(),
|
||||
e.iter_chain().last().unwrap().to_string(),
|
||||
)))),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user