From a474acbc5d9a1ff33cfb6b9d844e21c06a7bf756 Mon Sep 17 00:00:00 2001 From: Bugen Zhao Date: Mon, 6 Nov 2023 15:38:09 +0800 Subject: [PATCH] gate on pretty error Signed-off-by: Bugen Zhao --- src/utils/pgwire/src/pg_message.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/pgwire/src/pg_message.rs b/src/utils/pgwire/src/pg_message.rs index c33abee46a804..f57df5c308e08 100644 --- a/src/utils/pgwire/src/pg_message.rs +++ b/src/utils/pgwire/src/pg_message.rs @@ -19,6 +19,7 @@ use std::io::{Error, ErrorKind, IoSlice, Result, Write}; use byteorder::{BigEndian, ByteOrder}; /// Part of code learned from . use bytes::{Buf, BufMut, Bytes, BytesMut}; +use risingwave_common::util::env_var::env_var_is_true; use tokio::io::{AsyncRead, AsyncReadExt}; use crate::error_or_notice::ErrorOrNoticeMessage; @@ -634,7 +635,11 @@ impl<'a> BeMessage<'a> { // 'E' signalizes ErrorResponse messages buf.put_u8(b'E'); - let msg = format!("{:#}", error.as_ref().as_report()); + let msg = if env_var_is_true("RW_PRETTY_ERROR") { + format!("{:#}", error.as_ref().as_report()) + } else { + format!("{}", error.as_ref().as_report()) + }; write_err_or_notice(buf, &ErrorOrNoticeMessage::internal_error(&msg))?; }