diff options
author | Dave Whiteland <dave@mysociety.org> | 2012-05-04 16:55:06 +0100 |
---|---|---|
committer | Dave Whiteland <dave@mysociety.org> | 2012-05-04 16:55:06 +0100 |
commit | cac5e38fd088a56096897a5a7a19bea65113fadd (patch) | |
tree | 7c6ef6aaa116f485797490b119bce72812659236 | |
parent | db156a1d0311f8fe60736ffe307d324eee0b8480 (diff) |
improved error message capture from barnet responses
-rwxr-xr-x | bin/send-reports | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/bin/send-reports b/bin/send-reports index 612f29647..eb881d169 100755 --- a/bin/send-reports +++ b/bin/send-reports @@ -547,19 +547,28 @@ sub post_barnet_message { $problem->external_body( 'Barnet Borough Council' ); # better to use $problem->body()? $problem->send_method_used('barnet'); $return = 0; - } else { - $err_msg = "Failed (problem id $h{id}): service returned no external id"; + } else { + my @returned_items = split /<item[^>]*>/, $result->get_ET_RETURN; + my @messages = (); + foreach my $item (@returned_items) { + if ($item=~/<MESSAGE [^>]*>\s*(\S.*?)<\/MESSAGE>/) { # if there's a non-null MESSAGE in there, grab it + push @messages, $1; # best stab at extracting useful error message back from convoluted response + } + } + push @messages, "service returned no external id" unless @messages; + $err_msg = "Failed (problem id $h{id}): " . join(" \n ", @messages); } } else { my %fault = ( 'code' => $result->get_faultcode(), 'actor' => $result->get_faultactor(), 'string' => $result->get_faultstring(), - # 'detail' => $result->get_detail(), # possibly only contains debug info + 'detail' => $result->get_detail(), # possibly only contains debug info ); $fault{$_}=~s/^\s*|\s*$//g foreach keys %fault; $fault{actor}&&=" (actor: $fault{actor})"; - $err_msg = "Failed (problem id $h{id}): Fault $fault{code}$fault{actor}\n$fault{string}"; + $fault{'detail'} &&= "\n" . $fault{'detail'}; + $err_msg = "Failed (problem id $h{id}): Fault $fault{code}$fault{actor}\n$fault{string}$fault{detail}"; } }; |