Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print root cause error message to user facing interface #2486

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/servers/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/servers/src/mysql/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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(())
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/servers/src/postgres/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
)))),
}
}
Expand Down
Loading