diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2010-08-08 13:31:53 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2010-08-08 13:31:53 +0200 |
commit | 311e480283c8eb693419e7abada749fb80e10dda (patch) | |
tree | b2dd3ceb9e43ea07f80df9ea7539f5166971d4e0 /lib/WWW/Efa | |
parent | 5e15ca49a16f44e8229e47e44901180c2add5b18 (diff) |
Split up Error.pm into WWW::Efa::Error::{Backend,Setup}
Diffstat (limited to 'lib/WWW/Efa')
-rw-r--r-- | lib/WWW/Efa/Error.pm | 60 | ||||
-rw-r--r-- | lib/WWW/Efa/Error/Backend.pm | 48 | ||||
-rw-r--r-- | lib/WWW/Efa/Error/Setup.pm | 32 |
3 files changed, 80 insertions, 60 deletions
diff --git a/lib/WWW/Efa/Error.pm b/lib/WWW/Efa/Error.pm deleted file mode 100644 index a5fbf96..0000000 --- a/lib/WWW/Efa/Error.pm +++ /dev/null @@ -1,60 +0,0 @@ -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 arg for option %s: %s\n%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; 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; diff --git a/lib/WWW/Efa/Error/Setup.pm b/lib/WWW/Efa/Error/Setup.pm new file mode 100644 index 0000000..521bb55 --- /dev/null +++ b/lib/WWW/Efa/Error/Setup.pm @@ -0,0 +1,32 @@ +package WWW::Efa::Error::Setup; + +use strict; +use warnings; +use 5.010; + +use base 'Exporter'; + +our @EXPORT_OK = qw{}; + +sub new { + my ($obj, $key, $value, $msg) = @_; + my $ref = {}; + + $ref->{'key'} = $key; + $ref->{'value'} = $value; + $ref->{'message'} = $msg; + + return bless($ref, $obj); +} + +sub as_string { + my ($self) = @_; + my $ret; + + return sprintf( + "WWW::Efa setup error: Wrong arg for option %s: %s\n%s\n", + @{$self}{'key', 'value', 'message'}, + ); +} + +1; |