summaryrefslogtreecommitdiff
path: root/lib/WWW/Efa
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-08-06 19:24:03 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-08-06 19:24:03 +0200
commitee38a4b7cdf0032e35e8249eb45d255480895119 (patch)
tree45e43f819a3eea555bd0fa5fa22cd2505500771e /lib/WWW/Efa
parent308ec1bf336e39736916ba72053f16df0a9ba122 (diff)
Add Efa::Error class (probably sucks so far :p)
Diffstat (limited to 'lib/WWW/Efa')
-rw-r--r--lib/WWW/Efa/Error.pm60
1 files changed, 60 insertions, 0 deletions
diff --git a/lib/WWW/Efa/Error.pm b/lib/WWW/Efa/Error.pm
new file mode 100644
index 0000000..1f390bf
--- /dev/null
+++ b/lib/WWW/Efa/Error.pm
@@ -0,0 +1,60 @@
+package WWW::Efa::Error;
+
+use strict;
+use warnings;
+use 5.010;
+
+use base 'Exporter';
+
+our @EXPORT_OK = qw{};
+
+# source: internal / efa.vrr.de
+# type: internal: conf
+# efa.vrr.de: ambiguous / error / no data
+sub new {
+ my ($obj, $source, $type, $data) = @_;
+ my $ref = {};
+
+ $ref->{'source'} = $source;
+ $ref->{'type'} = $type;
+ $ref->{'data'} = $data;
+
+ return bless($ref, $obj);
+}
+
+sub as_string {
+ my ($self) = @_;
+ my $ret;
+
+ if ($self->{'source'} eq 'internal') {
+ $ret = sprintf(
+ "WWW::Efa config error: Wrong args for option %s. %s\n",
+ @{$self->{'data'}}
+ );
+ }
+ elsif ($self->{'source'} eq 'efa.vrr.de') {
+ 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;