line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DataLoader::Error; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
DataLoader::Error - simple error message object for use with DataLoader |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $error = DataLoader::Error->new("timed out"); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Recommended |
14
|
|
|
|
|
|
|
DataLoader->error("timed out") |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This is an internal error object and should be created via C<< DataLoader->error >>. |
19
|
|
|
|
|
|
|
Its only purpose is to mark error results within the cache and the return values of |
20
|
|
|
|
|
|
|
the batch loading function, to distinguish them from successful results. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
If a caller requests a data load and an object of this class is returned, it will |
23
|
|
|
|
|
|
|
trigger an exception for the caller. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHODS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=over |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
11
|
|
|
11
|
|
70284
|
use v5.14; |
|
11
|
|
|
|
|
49
|
|
32
|
11
|
|
|
11
|
|
61
|
use warnings; |
|
11
|
|
|
|
|
22
|
|
|
11
|
|
|
|
|
341
|
|
33
|
|
|
|
|
|
|
|
34
|
11
|
|
|
11
|
|
60
|
use Carp qw(croak); |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
2061
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item new ( message ) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Accepts C (a string) and creates the error object. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
11
|
|
|
11
|
1
|
5305
|
my ($class, $message) = @_; |
44
|
11
|
100
|
|
|
|
41
|
defined $message or croak 'message is required'; |
45
|
10
|
100
|
|
|
|
42
|
@_ == 2 or croak "too many arguments"; |
46
|
9
|
100
|
|
|
|
31
|
ref $message and croak "message is not a string"; |
47
|
|
|
|
|
|
|
|
48
|
8
|
|
|
|
|
49
|
bless { message => $message }, $class; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item message () |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Returns the message for this error object. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub message { |
58
|
8
|
|
|
8
|
1
|
535
|
my $self = shift; |
59
|
8
|
|
|
|
|
45
|
return $self->{message}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item throw () |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Equivalent to C<< die $self->message >>. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub throw { |
69
|
1
|
|
|
1
|
1
|
77
|
my $self = shift; |
70
|
1
|
|
|
|
|
4
|
die $self->message; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=back |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |