@@ -28,6 +28,32 @@ pub async fn handle_error(
28
28
29
29
let server_socket_addr = server_service_binding. bind_address ( ) ;
30
30
31
+ log_error ( error, client_socket_addr, server_socket_addr, opt_transaction_id, request_id) ;
32
+
33
+ trigger_udp_error_event (
34
+ error. clone ( ) ,
35
+ client_socket_addr,
36
+ server_service_binding,
37
+ opt_transaction_id,
38
+ opt_udp_server_stats_event_sender,
39
+ req_kind,
40
+ )
41
+ . await ;
42
+
43
+ Response :: from ( ErrorResponse {
44
+ transaction_id : opt_transaction_id. unwrap_or ( TransactionId ( I32 :: new ( 0 ) ) ) ,
45
+ message : error. to_string ( ) . into ( ) ,
46
+ } )
47
+ }
48
+
49
+ fn log_error (
50
+ error : & Error ,
51
+ client_socket_addr : SocketAddr ,
52
+ server_socket_addr : SocketAddr ,
53
+ opt_transaction_id : Option < TransactionId > ,
54
+
55
+ request_id : Uuid ,
56
+ ) {
31
57
match opt_transaction_id {
32
58
Some ( transaction_id) => {
33
59
let transaction_id = transaction_id. 0 . to_string ( ) ;
@@ -37,7 +63,17 @@ pub async fn handle_error(
37
63
tracing:: error!( target: UDP_TRACKER_LOG_TARGET , error = %error, %client_socket_addr, %server_socket_addr, %request_id, "response error" ) ;
38
64
}
39
65
}
66
+ }
67
+
68
+ async fn trigger_udp_error_event (
69
+ error : Error ,
70
+ client_socket_addr : SocketAddr ,
71
+ server_service_binding : ServiceBinding ,
72
+ opt_transaction_id : Option < TransactionId > ,
40
73
74
+ opt_udp_server_stats_event_sender : & crate :: event:: sender:: Sender ,
75
+ req_kind : Option < UdpRequestKind > ,
76
+ ) {
41
77
if opt_transaction_id. is_some ( ) {
42
78
// code-review: why we trigger an event only if transaction_id is present?
43
79
@@ -51,9 +87,4 @@ pub async fn handle_error(
51
87
. await ;
52
88
}
53
89
}
54
-
55
- Response :: from ( ErrorResponse {
56
- transaction_id : opt_transaction_id. unwrap_or ( TransactionId ( I32 :: new ( 0 ) ) ) ,
57
- message : error. to_string ( ) . into ( ) ,
58
- } )
59
90
}
0 commit comments