LS/SOAP/Fault.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 72 CC 12 SCAR 27.5
CC
12
Cov
0%
faultdetail
30.0
fault
20.0
errorcode
12.0
CRAP 15.6
1 # =====================================================================
2 # Copyright (c) 2002,2003 IBM Corporation
3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Common Public License v1.0
5 # which accompanies this distribution, and is available at
6 # http://www.opensource.org/licenses/cpl.php
7 #
8 # =====================================================================
9  
10 package LS::SOAP::Fault;
11  
12 use strict;
13 use warnings;
14  
15 use vars qw(@ISA);
16  
17 use SOAP::Lite;
18  
19 use LS::Service::Fault;
20  
21 @ISA = ( 'SOAP::Fault', 'LS::Service::Fault' );
22  
23 #
24 # LS::Service::Fault related methods
25 #
26  
27  
28 #
29 # fault -
30 #
31 sub fault {
32
33 my ($self, $msg) = @_;
34
35 if($msg) {
36  
37 unless($self->LS::Service::Fault::fault($msg)) {
38  
39 return $self
40 ->faultcode('Server')
41 ->faultstring('Internal error')
42 ->description('Unable to create base fault')
43 ->errorcode(500)
44 }
45 }
46  
47 my $fc = ($self->code < 500) ? 'Client' : 'Server';
48
49 return $self
50 ->faultcode($fc)
51 ->faultstring($self->message())
52 ->description('<![CDATA[' . $self->trace() . ']]>')
53 ->errorcode($self->code());
54 }
55  
56  
57 #
58 # SOAP::Fault related methods
59 #
60  
61 #
62 # errorcode -
63 #
64 sub errorcode {
65 my $self = UNIVERSAL::isa($_[0] => __PACKAGE__) ? shift->new() : __PACKAGE__->new();
66  
67 if (@_) { $self->{'errorcode'} = shift; return $self }
68 return $self->{'errorcode'};
69 }
70  
71  
72 #
73 # description -
74 #
75 sub description {
76 my $self = UNIVERSAL::isa($_[0] => __PACKAGE__) ? shift->new() : __PACKAGE__->new();
77  
78 if (@_) { $self->{'description'} = shift; return $self }
79 return $self->{'description'};
80 }
81  
82  
83 #
84 # faultdetail -
85 #
86 sub faultdetail {
87 my $self = UNIVERSAL::isa($_[0] => __PACKAGE__) ? shift->new() : __PACKAGE__->new();
88  
89 if (@_) { return $self }
90  
91 return
92 '<errorcode>' . (defined $self->errorcode() ? $self->errorcode() : '') . '</errorcode>' .
93 '<description>' . (defined $self->description() ? $self->description() : '') . '</description>';
94 }
95  
96 1;
97  
98 __END__