line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenInteract::Error; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Error.pm,v 1.6 2002/01/02 02:43:53 lachoy Exp $ |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$OpenInteract::Error::VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
6
|
use constant DEBUG => 0; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
290
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Collection of error tracking variables -- look ma, no 'use vars'! |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$OpenInteract::Error::user_msg = undef; |
14
|
|
|
|
|
|
|
$OpenInteract::Error::system_msg = undef; |
15
|
|
|
|
|
|
|
$OpenInteract::Error::type = undef; |
16
|
|
|
|
|
|
|
$OpenInteract::Error::package = undef; |
17
|
|
|
|
|
|
|
$OpenInteract::Error::filename = undef; |
18
|
|
|
|
|
|
|
$OpenInteract::Error::line = undef; |
19
|
|
|
|
|
|
|
$OpenInteract::Error::method = undef; |
20
|
|
|
|
|
|
|
$OpenInteract::Error::extra = (); |
21
|
|
|
|
|
|
|
$OpenInteract::Error::notes = undef; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub clear { |
24
|
0
|
|
|
0
|
0
|
|
$OpenInteract::Error::user_msg = undef; |
25
|
0
|
|
|
|
|
|
$OpenInteract::Error::system_msg = undef; |
26
|
0
|
|
|
|
|
|
$OpenInteract::Error::type = undef; |
27
|
0
|
|
|
|
|
|
$OpenInteract::Error::package = undef; |
28
|
0
|
|
|
|
|
|
$OpenInteract::Error::filename = undef; |
29
|
0
|
|
|
|
|
|
$OpenInteract::Error::line = undef; |
30
|
0
|
|
|
|
|
|
$OpenInteract::Error::method = undef; |
31
|
0
|
|
|
|
|
|
$OpenInteract::Error::extra = {}; |
32
|
0
|
|
|
|
|
|
$OpenInteract::Error::notes = undef; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Retrieve all the package variables in a hashref |
36
|
|
|
|
|
|
|
sub get { |
37
|
0
|
|
|
0
|
0
|
|
my ( $class ) = @_; |
38
|
0
|
|
|
|
|
|
return { user_msg => $OpenInteract::Error::user_msg, |
39
|
|
|
|
|
|
|
system_msg => $OpenInteract::Error::system_msg, |
40
|
|
|
|
|
|
|
type => $OpenInteract::Error::type, |
41
|
|
|
|
|
|
|
package => $OpenInteract::Error::package, |
42
|
|
|
|
|
|
|
filename => $OpenInteract::Error::filename, |
43
|
|
|
|
|
|
|
line => $OpenInteract::Error::line, |
44
|
|
|
|
|
|
|
method => $OpenInteract::Error::method, |
45
|
|
|
|
|
|
|
extra => $OpenInteract::Error::extra, |
46
|
|
|
|
|
|
|
notes => $OpenInteract::Error::notes }; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Set all package variables |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub set { |
53
|
0
|
|
|
0
|
0
|
|
my ( $class, $p ) = @_; |
54
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
349
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# First clean everything up so there's nothing |
57
|
|
|
|
|
|
|
# hanging around from a previous error |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
OpenInteract::Error->clear; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# Then set everything passed in |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
foreach my $key ( keys %{ $p } ) { |
|
0
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
warn "OpenInteractI::Error::set >> Setting error $key to $p->{ $key }\n" if ( DEBUG ); |
65
|
0
|
|
|
|
|
|
${ 'OpenInteract::Error::' . $key } = $p->{ $key }; |
|
0
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Set the caller information if the user didn't pass |
69
|
|
|
|
|
|
|
# anything in |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
0
|
|
|
|
unless ( $p->{package} and $p->{filename} and $p->{line} ) { |
|
|
|
0
|
|
|
|
|
72
|
0
|
|
|
|
|
|
( $OpenInteract::Error::package, |
73
|
|
|
|
|
|
|
$OpenInteract::Error::filename, |
74
|
|
|
|
|
|
|
$OpenInteract::Error::line ) = caller; |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
|
return OpenInteract::Error->get; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Class method -- really we just collect the caller info and |
81
|
|
|
|
|
|
|
# send it over to the error object... |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub throw { |
84
|
0
|
|
|
0
|
0
|
|
my ( $class, $p ) = @_; |
85
|
0
|
|
|
|
|
|
my $R = OpenInteract::Request->instance; |
86
|
0
|
0
|
0
|
|
|
|
unless ( $p->{package} and $p->{filename} and $p->{line} ) { |
|
|
|
0
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my ( $cpkg, $cfile, $cline ) = caller; |
88
|
0
|
|
|
|
|
|
$p->{package} = $cpkg; |
89
|
0
|
|
|
|
|
|
$p->{filename} = $cfile; |
90
|
0
|
|
|
|
|
|
$p->{line} = $cline; |
91
|
|
|
|
|
|
|
} |
92
|
0
|
|
0
|
|
|
|
my $error_obj_class = $R->CONFIG->{error}{error_object_class} || |
93
|
|
|
|
|
|
|
$R->CONFIG->{error_object_class}; |
94
|
0
|
|
|
|
|
|
return $error_obj_class->throw( $p ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
__END__ |