| 1 | package Furl::S3::Error; | ||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use Class::Accessor::Lite; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use XML::LibXML; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 4 | ▶ | use overload q{""} => \&stringify; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 4 | Class::Accessor::Lite->mk_accessors(qw(code http_code http_status message request_id host_id)); | |||||||||
| 8 | |||||||||||
| 9 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 10 | 0 | my( $class, $res ) = @_; | |||||||||
| 11 | my $self = bless { | ||||||||||
| 12 | http_code => $res->{code}, | ||||||||||
| 13 | http_status => $res->{msg}, | ||||||||||
| 14 | 0 | }, $class; | |||||||||
| 15 | 0 | ▶ | if ( my $xml = $res->{body} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 0 | $self->_parse_xml( $xml ); | |||||||||
| 17 | } | ||||||||||
| 18 | 0 | $self; | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub stringify { | ||||||||
|
Subroutine
stringify: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 22 | 0 | my $self = shift; | |||||||||
| 23 | 0 | ▶ | if ( $self->message ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | return sprintf('%s: %s', $self->code, $self->message); | |||||||||
| 25 | } | ||||||||||
| 26 | else { | ||||||||||
| 27 | 0 | return sprintf('HTTP Error: %s %s', $self->http_code, $self->http_status); | |||||||||
| 28 | } | ||||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | sub _parse_xml { | ||||||||
|
Subroutine
_parse_xml: not called CC=1 SCAR=6.9
| |||||||||||
| 32 | 0 | my( $self, $xml ) = @_; | |||||||||
| 33 | 0 | my $doc = XML::LibXML->new->parse_string( $xml ); | |||||||||
| 34 | 0 | my $code = $doc->findvalue('/Error/Code'); | |||||||||
| 35 | 0 | my $message = $doc->findvalue('/Error/Message'); | |||||||||
| 36 | 0 | my $request_id = $doc->findvalue('/Error/RequestId'); | |||||||||
| 37 | 0 | my $host_id = $doc->findvalue('/Error/HostId'); | |||||||||
| 38 | 0 | $self->code( $code ); | |||||||||
| 39 | 0 | $self->message( $message ); | |||||||||
| 40 | 0 | $self->request_id( $request_id ); | |||||||||
| 41 | 0 | $self->host_id( $host_id ); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 4 | 1; | |||||||||
| 45 | |||||||||||
| 46 | __END__ | ||||||||||