summaryrefslogtreecommitdiff
path: root/lib/Travel/Routing
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2014-01-12 18:01:59 +0100
committerDaniel Friesel <derf@finalrewind.org>2014-01-12 18:01:59 +0100
commit937a09c0845abd97a9b216d6e34b5747b95ac9f5 (patch)
treeaa499cfcc042872a9df778fef05aed1fb7d5edf9 /lib/Travel/Routing
parenta4f855c7f7d6fba7b6c249ecb174cb79acd55fad (diff)
Add an exception class for EFA backend errors, pass provided message
Diffstat (limited to 'lib/Travel/Routing')
-rw-r--r--lib/Travel/Routing/DE/VRR.pm13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/Travel/Routing/DE/VRR.pm b/lib/Travel/Routing/DE/VRR.pm
index c7193e1..603ac8b 100644
--- a/lib/Travel/Routing/DE/VRR.pm
+++ b/lib/Travel/Routing/DE/VRR.pm
@@ -33,9 +33,10 @@ use Exception::Class (
description => 'ambiguous input',
fields => [ 'post_key', 'possibilities' ],
},
- 'Travel::Routing::DE::VRR::Exception::NoConnections' => {
+ 'Travel::Routing::DE::VRR::Exception::Other' => {
isa => 'Travel::Routing::DE::VRR::Exception',
- description => 'got no connections',
+ description => 'EFA backend returned an error',
+ fields => ['message'],
},
);
@@ -580,12 +581,20 @@ sub parse {
my $xp_element = XML::LibXML::XPathExpression->new(
'//itdItinerary/itdRouteList/itdRoute');
+ my $xp_err = XML::LibXML::XPathExpression->new(
+ '//itdTripRequest/itdMessage[@type="error"]');
my $xp_odv = XML::LibXML::XPathExpression->new('//itdOdv');
for my $odv ( $tree->findnodes($xp_odv) ) {
$self->check_ambiguous($odv);
}
+ my $err = ( $tree->findnodes($xp_err) )[0];
+ if ($err) {
+ Travel::Routing::DE::VRR::Exception::Other->throw(
+ message => $err->textContent );
+ }
+
for my $part ( $tree->findnodes($xp_element) ) {
$self->parse_part($part);
}