blob: f35dcee4a303ee12a7857f619523cd2b489c700a (
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
56
57
58
59
60
61
62
63
|
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);
}
=head1 METHODS
=head2 $error->as_string()
Return the error as string, can directly be displayed to the user
=cut
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;
|