File Coverage

blib/lib/Net/Stomp/Producer/Exceptions.pm
Criterion Covered Total %
statement 56 58 96.5
branch n/a
condition 1 2 50.0
subroutine 20 21 95.2
pod 0 5 0.0
total 77 86 89.5


line stmt bran cond sub pod time code
1             package Net::Stomp::Producer::Exceptions;
2             $Net::Stomp::Producer::Exceptions::VERSION = '2.005';
3             {
4             $Net::Stomp::Producer::Exceptions::DIST = 'Net-Stomp-Producer';
5             }
6 4     4   1626 use Net::Stomp::MooseHelpers::Exceptions;
  4         713637  
  4         315  
7              
8             # ABSTRACT: exception classes for Net::Stomp::Producer
9              
10              
11             {
12             package Net::Stomp::Producer::Exceptions::StackTrace;
13             $Net::Stomp::Producer::Exceptions::StackTrace::VERSION = '2.005';
14             {
15             $Net::Stomp::Producer::Exceptions::StackTrace::DIST = 'Net-Stomp-Producer';
16             }
17 4     4   34 use Moose::Role;
  4         9  
  4         34  
18 4     4   18148 use namespace::autoclean;
  4         8  
  4         35  
19             with 'StackTrace::Auto';
20              
21             around _build_stack_trace_args => sub {
22             my ($orig,$self) = @_;
23              
24             my $ret = $self->$orig();
25             push @$ret, (
26             no_refs => 1,
27             respect_overload => 1,
28             message => '',
29             indent => 1,
30             );
31              
32             return $ret;
33             };
34             }
35              
36             {
37             package Net::Stomp::Producer::Exceptions::BadMessage;
38             $Net::Stomp::Producer::Exceptions::BadMessage::VERSION = '2.005';
39             {
40             $Net::Stomp::Producer::Exceptions::BadMessage::DIST = 'Net-Stomp-Producer';
41             }
42 4     4   4935 use Moose;with 'Throwable',
  4         9  
  4         22  
43             'Net::Stomp::MooseHelpers::Exceptions::Stringy',
44             'Net::Stomp::Producer::Exceptions::StackTrace';
45 4     4   21269 use namespace::autoclean;
  4         8  
  4         15  
46 4     4   2125 use Data::Dump 'pp';
  4         16673  
  4         583  
47             has message_body => ( is => 'ro', required => 1 );
48             has message_headers => ( is => 'ro', required => 0 );
49             has reason => ( is => 'ro', default => q{sending the message didn't work} );
50             has '+previous_exception' => ( init_arg => 'previous_exception' );
51              
52             sub as_string {
53 2     2 0 1916 my ($self) = @_;
54 2   50     72 sprintf "%s (%s): %s\n%s",
55             $self->reason,pp($self->message_body),
56             $self->previous_exception||'no previous exception',
57             $self->stack_trace->as_string;
58             }
59             __PACKAGE__->meta->make_immutable(inline_constructor=>0);
60             }
61              
62             {
63             package Net::Stomp::Producer::Exceptions::CantSerialize;
64             $Net::Stomp::Producer::Exceptions::CantSerialize::VERSION = '2.005';
65             {
66             $Net::Stomp::Producer::Exceptions::CantSerialize::DIST = 'Net-Stomp-Producer';
67             }
68 4     4   4722 use Moose;extends 'Net::Stomp::Producer::Exceptions::BadMessage';
  4         11  
  4         21  
69             has '+reason' => ( default => q{couldn't serialize message} );
70             __PACKAGE__->meta->make_immutable(inline_constructor=>0);
71             }
72              
73             {
74             package Net::Stomp::Producer::Exceptions::BadTransformer;
75             $Net::Stomp::Producer::Exceptions::BadTransformer::VERSION = '2.005';
76             {
77             $Net::Stomp::Producer::Exceptions::BadTransformer::DIST = 'Net-Stomp-Producer';
78             }
79 4     4   22296 use Moose;with 'Throwable',
  4         8  
  4         14  
80             'Net::Stomp::MooseHelpers::Exceptions::Stringy',
81             'Net::Stomp::Producer::Exceptions::StackTrace';
82 4     4   20872 use namespace::autoclean;
  4         8  
  4         34  
83             has transformer => ( is => 'ro', required => 1 );
84              
85             sub as_string {
86 0     0 0 0 my ($self) = @_;
87 0         0 sprintf qq{%s is not a valid transformer, it doesn't have a "transform" method\n%s},
88             $self->transformer,$self->stack_trace->as_string;
89             }
90             __PACKAGE__->meta->make_immutable(inline_constructor=>0);
91             }
92              
93             {
94             package Net::Stomp::Producer::Exceptions::BadMethod;
95             $Net::Stomp::Producer::Exceptions::BadMethod::VERSION = '2.005';
96             {
97             $Net::Stomp::Producer::Exceptions::BadMethod::DIST = 'Net-Stomp-Producer';
98             }
99 4     4   5256 use Moose;with 'Throwable',
  4         10  
  4         16  
100             'Net::Stomp::MooseHelpers::Exceptions::Stringy',
101             'Net::Stomp::Producer::Exceptions::StackTrace';
102 4     4   21127 use namespace::autoclean;
  4         9  
  4         17  
103             has sending_method_value => ( is => 'ro', required => 1 );
104             has method_to_call => ( is => 'ro', required => 1 );
105              
106             sub as_string {
107 1     1 0 1343 my ($self) = @_;
108 1         36 sprintf qq{%s is not a valid sending method, the connection object does not have a %s method\n%s},
109             $self->sending_method_value,$self->method_to_call,
110             $self->stack_trace->as_string;
111             }
112             __PACKAGE__->meta->make_immutable(inline_constructor=>0);
113             }
114              
115             {
116             package Net::Stomp::Producer::Exceptions::Invalid;
117             $Net::Stomp::Producer::Exceptions::Invalid::VERSION = '2.005';
118             {
119             $Net::Stomp::Producer::Exceptions::Invalid::DIST = 'Net-Stomp-Producer';
120             }
121 4     4   4759 use Moose;extends 'Net::Stomp::Producer::Exceptions::BadMessage';
  4         7  
  4         22  
122 4     4   20934 use Data::Dump 'pp';
  4         7  
  4         220  
123 4     4   23 use namespace::autoclean;
  4         7  
  4         29  
124             has transformer => ( is => 'ro', required => 1 );
125             has reason => ( is => 'ro', default => q{the message didn't pass validation} );
126              
127             sub as_string {
128 1     1 0 1358 my ($self) = @_;
129 1         33 sprintf "%s (%s): %s\n%s",
130             $self->reason,pp($self->message_body),$self->previous_exception,
131             $self->stack_trace->as_string;
132             }
133             __PACKAGE__->meta->make_immutable(inline_constructor=>0);
134             }
135              
136             {
137             package Net::Stomp::Producer::Exceptions::Transactional;
138             $Net::Stomp::Producer::Exceptions::Transactional::VERSION = '2.005';
139             {
140             $Net::Stomp::Producer::Exceptions::Transactional::DIST = 'Net-Stomp-Producer';
141             }
142 4     4   5047 use Moose;with 'Throwable',
  4         9  
  4         16  
143             'Net::Stomp::MooseHelpers::Exceptions::Stringy',
144             'Net::Stomp::Producer::Exceptions::StackTrace';
145 4     4   20975 use namespace::autoclean;
  4         8  
  4         17  
146              
147             sub as_string {
148 2     2 0 2954 my ($self) = @_;
149 2         7 sprintf qq{not inside a transaction\n%s},
150             $self->stack_trace->as_string;
151             }
152             __PACKAGE__->meta->make_immutable(inline_constructor=>0);
153             }
154              
155             1;
156              
157             __END__
158              
159             =pod
160              
161             =encoding UTF-8
162              
163             =head1 NAME
164              
165             Net::Stomp::Producer::Exceptions - exception classes for Net::Stomp::Producer
166              
167             =head1 VERSION
168              
169             version 2.005
170              
171             =head1 DESCRIPTION
172              
173             This file defines the following exception classes, all based on
174             L<Throwable>:
175              
176             =over 4
177              
178             =item C<Net::Stomp::Producer::Exceptions::BadMessage>
179              
180             Attributes: C<message_headers>, C<message_body>, C<reason>, C<stack_trace>.
181              
182             =item C<Net::Stomp::Producer::Exceptions::CantSerialize>
183              
184             Subclass of L</Net::Stomp::Producer::Exceptions::BadMessage>;
185             attributes: C<reason>.
186              
187             Throw when the serialization fails.
188              
189             =item C<Net::Stomp::Producer::Exceptions::BadTransformer>
190              
191             Attributes: C<transformer>, C<stack_trace>.
192              
193             Thrown when the transformer does not have a C<transform> method.
194              
195             =item C<Net::Stomp::Producer::Exceptions::BadMethod>
196              
197             Attributes: C<sending_method_value>, C<method_to_call>,
198             C<stack_trace>.
199              
200             Thrown when L<Net::Stomp::Producer/sending_method> is set to a value
201             that would require us to call a non-existent method on the connection.
202              
203             =item C<Net::Stomp::Producer::Exceptions::Invalid>
204              
205             Subclass of L</Net::Stomp::Producer::Exceptions::BadMessage>;
206             attributes: C<transformer>, C<reason>.
207              
208             Thrown when validation fails.
209              
210             =item C<Net::Stomp::Producer::Exceptions::Transactional>
211              
212             Attributes: C<stack_trace>.
213              
214             Thrown when you call
215             L<txn_commit|Net::Stomp::Producer::Transactional/txn_commit> or
216             L<txn_rollback|Net::Stomp::Producer::Transactional/txn_rollback> without a
217             corresponding L<txn_begin|Net::Stomp::Producer::Transactional/txn_begin>.
218             See L<Net::Stomp::Producer::Transactional> for details.
219              
220             =back
221              
222             =head1 AUTHOR
223              
224             Gianni Ceccarelli <gianni.ceccarelli@net-a-porter.com>
225              
226             =head1 COPYRIGHT AND LICENSE
227              
228             This software is copyright (c) 2012 by Net-a-porter.com.
229              
230             This is free software; you can redistribute it and/or modify it under
231             the same terms as the Perl 5 programming language system itself.
232              
233             =cut