From 5f87f2bb33116ae072b7320fe9cedace0050d5d1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 13 Aug 2010 17:28:54 +0200 Subject: Add $efa->setup_error() to replace $efa->{'error'} check --- bin/efa | 4 ++-- lib/WWW/Efa.pm | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/bin/efa b/bin/efa index ad57e01..b7b61d4 100755 --- a/bin/efa +++ b/bin/efa @@ -100,8 +100,8 @@ $efa = WWW::Efa->new( max_interchanges => $opt->{'max-change'}, ); -if ($efa->{'error'}) { - die $efa->{'error'}->as_string(); +if (my $err = $efa->setup_error()) { + die $err->as_string(); } if ($opt->{'test-parse'}) { diff --git a/lib/WWW/Efa.pm b/lib/WWW/Efa.pm index fc3ae37..58d55bd 100644 --- a/lib/WWW/Efa.pm +++ b/lib/WWW/Efa.pm @@ -407,6 +407,23 @@ sub new { return bless($ref, $obj); } +=head2 $efa->setup_error() + +In case WWW::Efa->new() encountered an error (usually invalid options), this +returns a B object describing the exact error. +Otherwise, returns nothing. + +=cut + +sub setup_error { + my ($self) = @_; + + if ($self->{'error'}) { + return $self->{'error'}; + } + return; +} + =head2 $efa->submit(%opts) Submit the query to B. -- cgit v1.2.3