From 85f4e5b763607450a25c4c684da0d06fb8bc301a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 3 Jul 2022 12:14:38 +0200 Subject: Traewelling: Custom log message für 409 Conflict; include raw error otherwise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Travelynx/Helper/Traewelling.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Travelynx/Helper/Traewelling.pm b/lib/Travelynx/Helper/Traewelling.pm index e71f38c..bd0aa45 100644 --- a/lib/Travelynx/Helper/Traewelling.pm +++ b/lib/Travelynx/Helper/Traewelling.pm @@ -354,6 +354,19 @@ sub checkin { my ($tx) = @_; if ( my $err = $tx->error ) { my $err_msg = "HTTP $err->{code} $err->{message}"; + if ( $tx->res->body ) { + if ( $err->{code} == 409 ) { + my $j = $tx->res->json; + $err_msg .= sprintf( +': Bereits in %s eingecheckt: https://traewelling.de/status/%d', + $j->{error}{lineName}, + $j->{error}{status_id} + ); + } + else { + $err_msg .= ' ' . $tx->res->body; + } + } if ( $err->{code} != 409 and $err->{code} != 406 and $err->{code} != 401 ) -- cgit v1.2.3