File tree Expand file tree Collapse file tree
pgdog/src/frontend/client/query_engine Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,10 +61,16 @@ impl QueryEngine {
6161
6262 if err. no_server ( ) {
6363 error ! ( "{} [{:?}]" , err, context. stream. peer_addr( ) ) ;
64+
65+ let error = ErrorResponse :: from_err ( & err) ;
66+
67+ self . hooks . on_engine_error ( context, & error) ?;
68+
6469 let bytes_sent = context
6570 . stream
66- . error ( ErrorResponse :: from_err ( & err ) , context. in_transaction ( ) )
71+ . error ( error , context. in_transaction ( ) )
6772 . await ?;
73+
6874 self . stats . sent ( bytes_sent) ;
6975 self . backend . disconnect ( ) ;
7076 self . router . reset ( ) ;
Original file line number Diff line number Diff line change @@ -45,4 +45,12 @@ impl QueryEngineHooks {
4545 ) -> Result < ( ) , Error > {
4646 Ok ( ( ) )
4747 }
48+
49+ pub ( super ) fn on_engine_error (
50+ & mut self ,
51+ context : & mut QueryEngineContext < ' _ > ,
52+ error : & ErrorResponse ,
53+ ) -> Result < ( ) , Error > {
54+ Ok ( ( ) )
55+ }
4856}
Original file line number Diff line number Diff line change @@ -365,12 +365,13 @@ impl QueryEngine {
365365 && context. client_request . executable ( )
366366 && !route. rollback_savepoint ( )
367367 {
368+ let error = ErrorResponse :: in_failed_transaction ( ) ;
369+
370+ self . hooks . on_engine_error ( context, & error) ?;
371+
368372 let bytes_sent = context
369373 . stream
370- . error (
371- ErrorResponse :: in_failed_transaction ( ) ,
372- context. in_transaction ( ) ,
373- )
374+ . error ( error, context. in_transaction ( ) )
374375 . await ?;
375376 self . stats . sent ( bytes_sent) ;
376377
Original file line number Diff line number Diff line change @@ -31,12 +31,14 @@ impl QueryEngine {
3131 }
3232 Err ( err) => {
3333 error ! ( "{:?} [{:?}]" , err, context. stream. peer_addr( ) ) ;
34+
35+ let error = ErrorResponse :: syntax ( err. to_string ( ) . as_str ( ) ) ;
36+
37+ self . hooks . on_engine_error ( context, & error) ?;
38+
3439 let bytes_sent = context
3540 . stream
36- . error (
37- ErrorResponse :: syntax ( err. to_string ( ) . as_str ( ) ) ,
38- context. in_transaction ( ) ,
39- )
41+ . error ( error, context. in_transaction ( ) )
4042 . await ?;
4143 self . stats . sent ( bytes_sent) ;
4244 return Ok ( false ) ;
You can’t perform that action at this time.
0 commit comments