Traewelling: Custom log message für 409 Conflict; include raw error otherwise

This commit is contained in:
Daniel Friesel 2022-07-03 12:14:38 +02:00
parent 3082316697
commit 85f4e5b763
No known key found for this signature in database
GPG key ID: 100D5BFB5166E005

View file

@ -354,6 +354,19 @@ sub checkin {
my ($tx) = @_; my ($tx) = @_;
if ( my $err = $tx->error ) { if ( my $err = $tx->error ) {
my $err_msg = "HTTP $err->{code} $err->{message}"; 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 if ( $err->{code} != 409
and $err->{code} != 406 and $err->{code} != 406
and $err->{code} != 401 ) and $err->{code} != 401 )