From 326c97625d65bbeae4cf6492e25cab8b584fa240 Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Mon, 10 Jul 2017 10:07:36 +0000 Subject: [PATCH 1/2] Add more details in warnings --- Changes | 1 + lib/Mojo/WebSocketProxy/CallingEngine.pm | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 6c591501..5cfadea0 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for Perl module Mojo::WebSocketProxy {{$NEXT}} + Add warning with transaction details failure, if available. 0.06 2017-06-01 03:05:17+00:00 UTC This introduces support for callbacks which return Future instances, diff --git a/lib/Mojo/WebSocketProxy/CallingEngine.pm b/lib/Mojo/WebSocketProxy/CallingEngine.pm index 092fbd60..de257d8c 100644 --- a/lib/Mojo/WebSocketProxy/CallingEngine.pm +++ b/lib/Mojo/WebSocketProxy/CallingEngine.pm @@ -144,7 +144,12 @@ sub call_rpc { my $api_response; if (!$res) { - warn "WrongResponse [$msg_type]"; + my $tx = $client->tx; + my $details = 'URL: ' . $tx->req->url; + if (my $err = $tx->error) { + $details .= ', code: ' . $err->{code} // 'n/a, response: ' . $err->{message}; + } + warn "WrongResponse [$msg_type], details: $details"; $api_response = $c->wsp_error($msg_type, 'WrongResponse', 'Sorry, an error occurred while processing your request.'); $c->send({json => $api_response}, $req_storage); return; From e6d2b3f6feac78b687e4c297bdca4e1a11d12b8f Mon Sep 17 00:00:00 2001 From: Ivan Baidakou Date: Tue, 18 Jul 2017 09:01:42 +0000 Subject: [PATCH 2/2] fix --- lib/Mojo/WebSocketProxy/CallingEngine.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Mojo/WebSocketProxy/CallingEngine.pm b/lib/Mojo/WebSocketProxy/CallingEngine.pm index de257d8c..44ffb2e5 100644 --- a/lib/Mojo/WebSocketProxy/CallingEngine.pm +++ b/lib/Mojo/WebSocketProxy/CallingEngine.pm @@ -147,7 +147,7 @@ sub call_rpc { my $tx = $client->tx; my $details = 'URL: ' . $tx->req->url; if (my $err = $tx->error) { - $details .= ', code: ' . $err->{code} // 'n/a, response: ' . $err->{message}; + $details .= ', code: ' . ($err->{code} // 'n/a') . ', response: ' . $err->{message}; } warn "WrongResponse [$msg_type], details: $details"; $api_response = $c->wsp_error($msg_type, 'WrongResponse', 'Sorry, an error occurred while processing your request.');