summaryrefslogtreecommitdiff
path: root/lib/WWW/Efa/Error/Backend.pm
blob: b6ffa75c97944c5d8ea13b101c2f73377f01716c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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;