[r418]: trunk / lib / SOAP / Fault.pm  Maximize  Restore  History

Download this file

59 lines (46 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package SOAP::Fault;
use strict;
use Carp ();
use SOAP::Trace ();
use overload fallback => 1, '""' => "stringify";
sub DESTROY { SOAP::Trace::objects('()') }
sub new {
my $self = shift;
unless (ref $self) {
my $class = $self;
$self = bless {} => $class;
SOAP::Trace::objects('()');
}
Carp::carp "Odd (wrong?) number of parameters in new()"
if $^W && (@_ & 1);
no strict qw(refs);
while (@_) {
my $method = shift;
$self->$method(shift)
if $self->can($method)
}
return $self;
}
sub stringify {
my $self = shift;
return join ': ', $self->faultcode, $self->faultstring;
}
sub BEGIN {
no strict 'refs';
for my $method (qw(faultcode faultstring faultactor faultdetail)) {
my $field = '_' . $method;
*$method = sub {
my $self = UNIVERSAL::isa($_[0] => __PACKAGE__)
? shift->new
: __PACKAGE__->new;
if (@_) {
$self->{$field} = shift;
return $self
}
return $self->{$field};
}
}
*detail = \&faultdetail;
}
1;
__END__