summaryrefslogtreecommitdiff
path: root/lib/WWW/Efa/Error/Backend.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/WWW/Efa/Error/Backend.pm')
-rw-r--r--lib/WWW/Efa/Error/Backend.pm64
1 files changed, 38 insertions, 26 deletions
diff --git a/lib/WWW/Efa/Error/Backend.pm b/lib/WWW/Efa/Error/Backend.pm
index b6ffa75..930fed5 100644
--- a/lib/WWW/Efa/Error/Backend.pm
+++ b/lib/WWW/Efa/Error/Backend.pm
@@ -1,5 +1,27 @@
package WWW::Efa::Error::Backend;
+=head1 NAME
+
+WWW::Efa::Error::Backend - WWW::Efa unknown error from efa.vrr.de
+
+=head1 SYNOPSIS
+
+ use WWW::Efa::Error::Backend;
+
+ my $error = WWW::Efa::Error::Backend->new(
+ 'Yadda Yadda'
+ );
+
+ die $error->as_string();
+ # WWW::Efa error from efa.vrr.de:
+ # Yadda Yadda
+
+=head1 DESCRIPTION
+
+Received an unknown error from efa.vrr.de
+
+=cut
+
use strict;
use warnings;
use 5.010;
@@ -7,42 +29,32 @@ use 5.010;
use base 'Exporter';
our @EXPORT_OK = qw{};
+our @ISA = ('WWW::Efa::Error');
sub new {
- my ($obj, $type, $data) = @_;
+ my ($obj, $msg) = @_;
my $ref = {};
- $ref->{'type'} = $type;
- $ref->{'data'} = $data;
+ $ref->{'message'} = $msg;
return bless($ref, $obj);
}
+=head1 METHODS
+
+=head2 $error->as_string()
+
+Return the error as string, can directly be displayed to the user
+
+=cut
+
sub as_string {
my ($self) = @_;
- my $ret;
-
- given ($self->{'type'}) {
- when ('no data') {
- $ret = "WWW::Efa: efa.vrr.de returned no data\n";
- }
- when ('ambiguous') {
- $ret = sprintf(
- "WWW::Efa: efa.vrr.de: Ambiguous input for %s:\n",
- shift(@{$self->{'data'}}),
- );
- foreach my $possible (@{$self->{'data'}}) {
- $ret .= "\t${possible}\n";
- }
- }
- when ('error') {
- $ret = sprintf(
- "WWW::Efa: efa.vrr.de error:\n%s\n",
- $self->{'data'},
- );
- }
- }
- return $ret;
+
+ return sprintf(
+ "WWW::Efa error from efa.vrr.de:\n%s\n",
+ $self->{'message'},
+ );
}
1;