summaryrefslogtreecommitdiff
path: root/lib/WWW/Efa/Error/Setup.pm
blob: e3de3e3eb831d0f5f4c22dee1fbf376ae2e17510 (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
49
50
51
52
53
54
55
package WWW::Efa::Error::Setup;

=head1 NAME

WWW::Efa::Error::Setup - WWW::Efa error, happened in ->new()

=head1 SYNOPSIS

    use WWW::Efa::Error::Setup;

    my $error = WWW::Efa::Error::Setup->new(
        'max_interchanges', '-1', 'Must be positive'
    );

    die $error->as_string();
    # WWW::Efa setup error: Wrong arg for option max_interchanges: -1
    # Must be positive

=head1 DESCRIPTION

Class for all WWW::Efa-internal errors occuring during initialization. Usually
caused by missing or invalid setup arguments.

=cut

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;