From 893ee14e4d3ca267777cc2d929d89bb47d13a2fd Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 21 Feb 2025 20:36:16 +0100 Subject: Fix new_p --- lib/Travel/Status/DE/DBRIS.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Travel/Status/DE/DBRIS.pm b/lib/Travel/Status/DE/DBRIS.pm index 57560ef..196d8ba 100644 --- a/lib/Travel/Status/DE/DBRIS.pm +++ b/lib/Travel/Status/DE/DBRIS.pm @@ -186,7 +186,7 @@ sub new_p { my $self = $obj->new( %conf, async => 1 ); $self->{promise} = $conf{promise}; - $self->get_with_cache_p( $self->{url} )->then( + $self->get_with_cache_p( $self->{req} )->then( sub { my ($content) = @_; $self->{raw_json} = $self->{json}->decode($content); @@ -203,8 +203,12 @@ sub new_p { elsif ( $conf{formation} ) { $self->parse_formation( $conf{formation} ); } + + if ( $self->errstr ) { + $promise->reject( $self->errstr, $self ); + } else { - $promise->reject( 'dead code path reached in new_p', $self ); + $promise->resolve($self); } return; } -- cgit v1.2.3