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.pm48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/WWW/Efa/Error/Backend.pm b/lib/WWW/Efa/Error/Backend.pm
new file mode 100644
index 0000000..b6ffa75
--- /dev/null
+++ b/lib/WWW/Efa/Error/Backend.pm
@@ -0,0 +1,48 @@
+package WWW::Efa::Error::Backend;
+
+use strict;
+use warnings;
+use 5.010;
+
+use base 'Exporter';
+
+our @EXPORT_OK = qw{};
+
+sub new {
+ my ($obj, $type, $data) = @_;
+ my $ref = {};
+
+ $ref->{'type'} = $type;
+ $ref->{'data'} = $data;
+
+ return bless($ref, $obj);
+}
+
+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;
+}
+
+1;