| 1 | package REST::Consumer::Exception; | ||||||||||
| 2 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | # an exception is always true | ||||||||||
| 6 | 9 | ▶ | use overload bool => sub {1}, '""' => 'as_string', fallback => 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 12 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||
| 9 | 12 | my ($class, %args) = @_; | |||||||||
| 10 | my $self = { | ||||||||||
| 11 | request => $args{request}, | ||||||||||
| 12 | response => $args{response}, | ||||||||||
| 13 | attempts => $args{attempts}, | ||||||||||
| 14 | 12 | }; | |||||||||
| 15 | |||||||||||
| 16 | # get the immediate non-REST::Consumer caller | ||||||||||
| 17 | # like Carp::croak for exception objects | ||||||||||
| 18 | 12 | my ($package, $filename, $line) = caller; | |||||||||
| 19 | 12 | my $counter = 1; | |||||||||
| 20 | 12 | ▶ | while ($package =~ /^REST::Consumer/) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | 57 | ($package, $filename, $line) = caller($counter++); | |||||||||
| 22 | 57 | ▶ | last if $counter > 10; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 12 | $self->{_immediate_caller} = "$filename line $line"; | |||||||||
| 26 | |||||||||||
| 27 | 12 | return bless $self, $class; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 1 | ▶ | sub request { return shift->{request} } | ||||||||
|
Subroutine
request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 31 | |||||||||||
| 32 | 1 | ▶ | sub response { return shift->{response} } | ||||||||
|
Subroutine
response: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 33 | |||||||||||
| 34 | 12 | ▶ | sub throw { | ||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 35 | 12 | my $class = shift; | |||||||||
| 36 | 12 | die $class->new(@_); | |||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | # as_string is an abstract method | ||||||||||
| 40 | # implemented by this class's descendants | ||||||||||
| 41 | |||||||||||
| 42 | 9 | 1; | |||||||||