line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/bin/false |
2
|
|
|
|
|
|
|
# PODNAME: BZ::Client::Exception |
3
|
|
|
|
|
|
|
# ABSTRACT: Exception class thrown by BZ::Client in case of errors. |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
5
|
use warnings 'all'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
154
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package BZ::Client::Exception; |
9
|
|
|
|
|
|
|
$BZ::Client::Exception::VERSION = '4.4002'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub throw { |
12
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
13
|
0
|
|
|
|
|
|
die $class->new(@_) |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
18
|
0
|
|
|
|
|
|
my $self = { @_ }; |
19
|
0
|
|
0
|
|
|
|
bless($self, ref($class) || $class); |
20
|
0
|
|
|
|
|
|
return $self |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub message { |
24
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
25
|
0
|
|
|
|
|
|
return $self->{'message'} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub xmlrpc_code { |
29
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
30
|
0
|
|
|
|
|
|
return $self->{'xmlrpc_code'} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub http_code { |
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
return $self->{'http_code'} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
BZ::Client::Exception - Exception class thrown by BZ::Client in case of errors. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 4.4002 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
BZ::Client does not return error codes or do similar stuff. |
57
|
|
|
|
|
|
|
Instead, it throws instances of BZ::Client::Exception. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $exception = BZ::Client::Exception->new( message => $message, |
60
|
|
|
|
|
|
|
http_code => $httpCode, |
61
|
|
|
|
|
|
|
xmlrpc_code => $xmlrpcCode ); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
BZ::Client::Exception->throw( message => $message, |
64
|
|
|
|
|
|
|
http_code => $httpCode, |
65
|
|
|
|
|
|
|
xmlrpc_code => $xmlrpcCode ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 new |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Creates the exception object |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 throw |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Creates the exception object then dies, so make sure you catch it! |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 message |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns the error message text |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 xmlrpc_code |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Returns the error code from XMLRPC |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 http_code |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Returns the http code (200, 404, etc) |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 EXAMPLE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Here are two examples. The first uses Perl's inbuilt eval() function, the |
92
|
|
|
|
|
|
|
second uses the Try::Tiny module. Further alternatives exist and may be |
93
|
|
|
|
|
|
|
perfectly good options if they suit you. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head2 eval |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
use BZ::Client; |
98
|
|
|
|
|
|
|
use BZ::Client::Bug::Attachment; |
99
|
|
|
|
|
|
|
use v5.10; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $client = BZ::Client->new( %etc ); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
eval { |
104
|
|
|
|
|
|
|
my $att = BZ::Client::Bug::Attachment->get($client, { ids => 30505 }); |
105
|
|
|
|
|
|
|
}; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
if ($@) { |
108
|
|
|
|
|
|
|
say 'An Error Occured'; |
109
|
|
|
|
|
|
|
say 'Message: ', $@->message(); |
110
|
|
|
|
|
|
|
say 'HTTP Code: ', $@->http_code() if $@->http_code(); |
111
|
|
|
|
|
|
|
say 'XMLrpc Code: ', $@->xmlrpc_code() if $@->xmlrpc_code(); |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 Try::Tiny |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
use BZ::Client; |
117
|
|
|
|
|
|
|
use BZ::Client::Bug::Attachment; |
118
|
|
|
|
|
|
|
use Try::Tiny; |
119
|
|
|
|
|
|
|
use v5.10; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
my $client = BZ::Client->new( %etc ); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
try { |
124
|
|
|
|
|
|
|
my $att = BZ::Client::Bug::Attachment->get($client, { ids => 30505 }); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
catch { |
128
|
|
|
|
|
|
|
say 'An Error Occured'; |
129
|
|
|
|
|
|
|
say 'Message: ', $_->message(); |
130
|
|
|
|
|
|
|
say 'HTTP Code: ', $_->http_code() if $_->http_code(); |
131
|
|
|
|
|
|
|
say 'XMLrpc Code: ', $_->xmlrpc_code() if $_->xmlrpc_code(); |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 SEE ALSO |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
L<BZ::Client> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 AUTHORS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Dean Hamstead <dean@bytefoundry.com.au> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Jochen Wiedmann <jochen.wiedmann@gmail.com> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Dean Hamstad. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |