File tree Expand file tree Collapse file tree 6 files changed +19
-7
lines changed Expand file tree Collapse file tree 6 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use trino_lb_persistence::Persistence;
2121
2222use crate :: {
2323 cluster_group_manager:: { self , ClusterStats } ,
24+ error_formatting:: snafu_error_to_string,
2425 http_server:: AppState ,
2526} ;
2627
@@ -71,7 +72,7 @@ impl IntoResponse for Error {
7172 Error :: GetQueryCounterForGroup { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
7273 Error :: GetAllClusterStates { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
7374 } ;
74- ( status_code, format ! ( "{ self}" ) ) . into_response ( )
75+ ( status_code, snafu_error_to_string ( & self ) ) . into_response ( )
7576 }
7677}
7778
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use prometheus::{Encoder, TextEncoder};
99use snafu:: { ResultExt , Snafu } ;
1010use tracing:: { instrument, warn} ;
1111
12- use crate :: http_server:: AppState ;
12+ use crate :: { error_formatting :: snafu_error_to_string , http_server:: AppState } ;
1313
1414#[ derive( Snafu , Debug ) ]
1515pub enum Error {
@@ -23,7 +23,11 @@ pub enum Error {
2323impl IntoResponse for Error {
2424 fn into_response ( self ) -> Response {
2525 warn ! ( error = ?self , "Error while processing metrics request" ) ;
26- ( StatusCode :: INTERNAL_SERVER_ERROR , format ! ( "{self:?}" ) ) . into_response ( )
26+ (
27+ StatusCode :: INTERNAL_SERVER_ERROR ,
28+ snafu_error_to_string ( & self ) ,
29+ )
30+ . into_response ( )
2731 }
2832}
2933
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ use tracing::{instrument, warn};
1212
1313use crate :: {
1414 cluster_group_manager:: { self , ClusterStats } ,
15+ error_formatting:: snafu_error_to_string,
1516 http_server:: AppState ,
1617} ;
1718
@@ -33,7 +34,7 @@ impl IntoResponse for Error {
3334 Error :: GetAllClusterStates { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
3435 Error :: RenderTemplate { .. } => StatusCode :: INTERNAL_SERVER_ERROR ,
3536 } ;
36- ( status_code, format ! ( "{ self}" ) ) . into_response ( )
37+ ( status_code, snafu_error_to_string ( & self ) ) . into_response ( )
3738 }
3839}
3940
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ use tracing::{instrument, warn};
1111use trino_lb_core:: TrinoLbQueryId ;
1212use trino_lb_persistence:: Persistence ;
1313
14- use crate :: http_server:: AppState ;
14+ use crate :: { error_formatting :: snafu_error_to_string , http_server:: AppState } ;
1515
1616#[ derive( Snafu , Debug ) ]
1717pub enum Error {
@@ -36,7 +36,7 @@ impl IntoResponse for Error {
3636 Error :: QueryIdMissing => StatusCode :: BAD_REQUEST ,
3737 Error :: QueryIdNotFound { .. } => StatusCode :: NOT_FOUND ,
3838 } ;
39- ( status_code, format ! ( "{ self}" ) ) . into_response ( )
39+ ( status_code, snafu_error_to_string ( & self ) ) . into_response ( )
4040 }
4141}
4242
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ use url::Url;
2828
2929use crate :: {
3030 cluster_group_manager:: { self , SendToTrinoResponse } ,
31+ error_formatting:: snafu_error_to_string,
3132 http_server:: AppState ,
3233 maintenance:: leftover_queries:: UPDATE_QUEUED_QUERY_LAST_ACCESSED_INTERVAL ,
3334} ;
@@ -131,7 +132,11 @@ pub enum Error {
131132impl IntoResponse for Error {
132133 fn into_response ( self ) -> Response {
133134 warn ! ( error = ?self , "Error while processing request" ) ;
134- ( StatusCode :: INTERNAL_SERVER_ERROR , format ! ( "{self:?}" ) ) . into_response ( )
135+ (
136+ StatusCode :: INTERNAL_SERVER_ERROR ,
137+ snafu_error_to_string ( & self ) ,
138+ )
139+ . into_response ( )
135140 }
136141}
137142
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ use crate::{args::Args, http_server::start_http_server};
2323
2424mod args;
2525mod cluster_group_manager;
26+ mod error_formatting;
2627mod http_server;
2728mod maintenance;
2829mod metrics;
You can’t perform that action at this time.
0 commit comments