summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-21 19:47:54 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-21 19:47:54 +0200
commit870e4333a82e8cbc28f3d182564ee29cc83c74ed (patch)
treee3dd2ddf7b380f844638acf3b73a803c1a2d07ae
parente27e37190e549cac1e964ba3dbb5f7bea585fd19 (diff)
improve promise->reject error messages1.17.4
-rw-r--r--lib/Travelynx/Helper/HAFAS.pm33
1 files changed, 20 insertions, 13 deletions
diff --git a/lib/Travelynx/Helper/HAFAS.pm b/lib/Travelynx/Helper/HAFAS.pm
index 1fd66b5..be13bd7 100644
--- a/lib/Travelynx/Helper/HAFAS.pm
+++ b/lib/Travelynx/Helper/HAFAS.pm
@@ -44,7 +44,8 @@ sub get_polyline_p {
if ( my $err = $tx->error ) {
$promise->reject(
- "GET $url returned HTTP $err->{code} $err->{message}");
+"hafas->get_polyline_p($url) returned HTTP $err->{code} $err->{message}"
+ );
return;
}
@@ -91,7 +92,8 @@ sub get_polyline_p {
. $train->line
. ": IRIS route does not agree with HAFAS route: $iris_stations != $hafas_stations"
);
- $promise->reject('polyline route mismatch');
+ $promise->reject(
+ "hafas->get_polyline_p($url): polyline route mismatch");
}
else {
$promise->resolve($ret);
@@ -101,7 +103,7 @@ sub get_polyline_p {
)->catch(
sub {
my ($err) = @_;
- $promise->reject($err);
+ $promise->reject("hafas->get_polyline_p($url): $err");
return;
}
)->wait;
@@ -144,7 +146,9 @@ sub get_tripid_p {
return;
}
}
- $promise->reject;
+ $promise->reject( 'hafas->get_tripid_p: train '
+ . $train->train_no
+ . ' not found' );
return;
}
)->catch(
@@ -175,7 +179,8 @@ sub get_rest_p {
if ( my $err = $tx->error ) {
$promise->reject(
- "GET $url returned HTTP $err->{code} $err->{message}");
+"hafas->get_rest_p($url) returned HTTP $err->{code} $err->{message}"
+ );
return;
}
@@ -187,8 +192,8 @@ sub get_rest_p {
)->catch(
sub {
my ($err) = @_;
- $self->{log}->warn("get($url): $err");
- $promise->reject($err);
+ $self->{log}->warn("hafas->get_rest_p($url): $err");
+ $promise->reject("hafas->get_rest_p($url): $err");
return;
}
)->wait;
@@ -212,7 +217,8 @@ sub get_json_p {
if ( my $err = $tx->error ) {
$promise->reject(
- "GET $url returned HTTP $err->{code} $err->{message}");
+"hafas->get_json_p($url) returned HTTP $err->{code} $err->{message}"
+ );
return;
}
@@ -230,8 +236,8 @@ sub get_json_p {
)->catch(
sub {
my ($err) = @_;
- $self->{log}->warn("get($url): $err");
- $promise->reject($err);
+ $self->{log}->warn("hafas->get_json_p($url): $err");
+ $promise->reject("hafas->get_json_p($url): $err");
return;
}
)->wait;
@@ -255,7 +261,8 @@ sub get_xml_p {
if ( my $err = $tx->error ) {
$promise->reject(
- "GET $url returned HTTP $err->{code} $err->{message}");
+"hafas->get_xml_p($url) returned HTTP $err->{code} $err->{message}"
+ );
return;
}
@@ -312,8 +319,8 @@ sub get_xml_p {
)->catch(
sub {
my ($err) = @_;
- $self->{log}->warn("get($url): $err");
- $promise->reject($err);
+ $self->{log}->warn("hafas->get_xml_p($url): $err");
+ $promise->reject("hafas->get_xml_p($url): $err");
return;
}
)->wait;