File Coverage

blib/lib/WebService/Cmis/ServerException.pm
Criterion Covered Total %
statement 9 19 47.3
branch n/a
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 24 54.1


line stmt bran cond sub pod time code
1             package WebService::Cmis::ServerException;
2              
3             =head1 NAME
4              
5             WebService::Cmis::ServerException
6              
7             =head1 DESCRIPTION
8              
9             This exception will be raised when an error happened on the server
10             while the client communicates with it.
11              
12             See L.
13              
14             Parent class: Error
15              
16             =cut
17              
18 1     1   3994 use strict;
  1         3  
  1         36  
19 1     1   6 use warnings;
  1         2  
  1         36  
20 1     1   6 use Error ();
  1         2  
  1         224  
21             our @ISA = qw(Error);
22              
23             =head1 METHODS
24              
25             =over 4
26              
27             =item new()
28              
29             =cut
30              
31             sub new {
32 0     0 1   my ($class, $client) = @_;
33              
34             #print STDERR "creating a ServerException class=$class\n";
35              
36 0           my $reason = $client->responseStatusLine;
37 0           my $url = $client->responseBase;
38              
39 0           my $text = $client->responseContent;
40              
41             # clean up response to make *any* sense of it.
42             # why is it so hard to track the reason for a 500 server error
43 0           $text =~ s///gs; # remove all HTML comments
44 0           $text =~ s/<(?!nop)[^>]*>//g; # remove all HTML tags except
45 0           $text =~ s/\&[a-z]+;/ /g; # remove entities
46 0           $text =~ s/\n[^\n]+\.java:.*//gs; # remove java stack trace
47 0           $text =~ s/^\s+//gm;
48              
49 0           return $class->SUPER::new(-text => "$reason at $url\n\n" . $text);
50             }
51              
52             =back
53              
54             =head1 COPYRIGHT AND LICENSE
55              
56             Copyright 2012-2013 Michael Daum
57              
58             This module is free software; you can redistribute it and/or modify it under
59             the same terms as Perl itself. See F.
60              
61             =cut
62              
63             1;
64