File Coverage

blib/lib/Email/Sender/Failure.pm
Criterion Covered Total %
statement 18 21 85.7
branch 3 6 50.0
condition n/a
subroutine 7 7 100.0
pod 1 2 50.0
total 29 36 80.5


line stmt bran cond sub pod time code
1             package Email::Sender::Failure 2.600;
2             # ABSTRACT: a report of failure from an email sending transport
3              
4 16     16   122823 use Moo;
  16         38532  
  16         75  
5             extends 'Throwable::Error';
6              
7 16     16   8330 use Carp ();
  16         38  
  16         373  
8 16     16   4853 use MooX::Types::MooseLike::Base qw(ArrayRef);
  16         65398  
  16         4170  
9              
10             #pod =attr message
11             #pod
12             #pod This method returns the failure message, which should describe the failure.
13             #pod Failures stringify to this message.
14             #pod
15             #pod =attr code
16             #pod
17             #pod This returns the numeric code of the failure, if any. This is mostly useful
18             #pod for network protocol transports like SMTP. This may be undefined.
19             #pod
20             #pod =cut
21              
22             has code => (
23             is => 'ro',
24             );
25              
26             #pod =attr recipients
27             #pod
28             #pod This returns a list of addresses to which the email could not be sent.
29             #pod
30             #pod =cut
31              
32             has recipients => (
33             isa => ArrayRef,
34             default => sub { [] },
35             writer => '_set_recipients',
36             reader => '__get_recipients',
37             is => 'rw',
38             accessor => undef,
39             );
40              
41 14     14   21 sub __recipients { @{$_[0]->__get_recipients} }
  14         90  
42              
43             sub recipients {
44 14     14 1 1764 my ($self) = @_;
45 14 50       53 return $self->__recipients if wantarray;
46 0 0       0 return if ! defined wantarray;
47              
48 0         0 Carp::carp("recipients in scalar context is deprecated and WILL BE REMOVED");
49 0         0 return $self->__get_recipients;
50             }
51              
52             #pod =method throw
53             #pod
54             #pod This method can be used to instantiate and throw an Email::Sender::Failure
55             #pod object at once.
56             #pod
57             #pod Email::Sender::Failure->throw(\%arg);
58             #pod
59             #pod Instead of a hashref of args, you can pass a single string argument which will
60             #pod be used as the C of the new failure.
61             #pod
62             #pod =cut
63              
64             sub BUILD {
65 29     29 0 56097 my ($self) = @_;
66 29 100       518 Carp::confess("message must contain non-space characters")
67             unless $self->message =~ /\S/;
68             }
69              
70             #pod =head1 SEE ALSO
71             #pod
72             #pod =over
73             #pod
74             #pod =item * L
75             #pod
76             #pod =item * L
77             #pod
78             #pod =item * L
79             #pod
80             #pod =back
81             #pod
82             #pod =cut
83              
84 16     16   136 no Moo;
  16         35  
  16         153  
85             1;
86              
87             __END__