| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OpenInteract2::Exception; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# $Id: Exception.pm,v 1.12 2005/03/17 14:57:58 sjn Exp $ |
|
4
|
|
|
|
|
|
|
|
|
5
|
86
|
|
|
86
|
|
37239
|
use strict; |
|
|
86
|
|
|
|
|
188
|
|
|
|
86
|
|
|
|
|
4008
|
|
|
6
|
86
|
|
|
86
|
|
519
|
use Carp qw( carp ); |
|
|
86
|
|
|
|
|
190
|
|
|
|
86
|
|
|
|
|
11316
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$OpenInteract2::Exception::VERSION = sprintf("%d.%02d", q$Revision: 1.12 $ =~ /(\d+)\.(\d+)/); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Declare some of our exceptions |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Exception::Class ( |
|
13
|
86
|
|
|
|
|
1191
|
'OpenInteract2::Exception::Application' => { |
|
14
|
|
|
|
|
|
|
isa => 'OpenInteract2::Exception', |
|
15
|
|
|
|
|
|
|
description => 'Generic application errors', |
|
16
|
|
|
|
|
|
|
fields => [ 'oi_package' ], |
|
17
|
|
|
|
|
|
|
}, |
|
18
|
|
|
|
|
|
|
'OpenInteract2::Exception::Datasource' => { |
|
19
|
|
|
|
|
|
|
isa => 'OpenInteract2::Exception', |
|
20
|
|
|
|
|
|
|
description => 'Datasource errors', |
|
21
|
|
|
|
|
|
|
fields => [ 'datasource_name', 'datasource_type', 'connect_params' ], |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
86
|
|
|
86
|
|
102310
|
); |
|
|
86
|
|
|
|
|
959677
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
@OpenInteract2::Exception::ISA = qw( Exporter Exception::Class::Base ); |
|
26
|
|
|
|
|
|
|
@OpenInteract2::Exception::EXPORT_OK = qw( |
|
27
|
|
|
|
|
|
|
oi_error oi_app_error oi_datasource_error oi_param_error oi_security_error |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
require OpenInteract2::Exception::Parameter; |
|
31
|
|
|
|
|
|
|
require OpenInteract2::Exception::Security; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Exported shortcuts |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub oi_error { |
|
36
|
|
|
|
|
|
|
# carp "throwing oi_error..."; |
|
37
|
0
|
|
|
0
|
|
|
my ( $msg, %params ) = _massage( @_ ); |
|
38
|
0
|
|
|
|
|
|
goto &Exception::Class::Base::throw( __PACKAGE__, |
|
39
|
|
|
|
|
|
|
message => $msg, %params ); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub oi_app_error { |
|
43
|
|
|
|
|
|
|
# carp "throwing oi_app_error..."; |
|
44
|
0
|
|
|
0
|
|
|
my ( $msg, %params ) = _massage( @_ ); |
|
45
|
0
|
|
|
|
|
|
goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Application', |
|
46
|
|
|
|
|
|
|
message => $msg, %params ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub oi_datasource_error { |
|
50
|
|
|
|
|
|
|
# carp "throwing oi_datasource_error..."; |
|
51
|
0
|
|
|
0
|
|
|
my ( $msg, %params ) = _massage( @_ ); |
|
52
|
0
|
|
|
|
|
|
goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Datasource', |
|
53
|
|
|
|
|
|
|
message => $msg, %params ); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub oi_param_error { |
|
57
|
|
|
|
|
|
|
# carp "throwing oi_param_error..."; |
|
58
|
0
|
|
|
0
|
|
|
my ( $msg, %params ) = _massage( @_ ); |
|
59
|
0
|
|
|
|
|
|
goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Parameter', |
|
60
|
|
|
|
|
|
|
message => $msg, %params ); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub oi_security_error { |
|
64
|
|
|
|
|
|
|
# carp "throwing oi_security_error..."; |
|
65
|
0
|
|
|
0
|
|
|
my ( $msg, %params ) = _massage( @_ ); |
|
66
|
0
|
|
|
|
|
|
goto &Exception::Class::Base::throw( 'OpenInteract2::Exception::Security', |
|
67
|
|
|
|
|
|
|
message => $msg, %params ); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Override 'throw' so we can massage the message and parameters into |
|
71
|
|
|
|
|
|
|
# the right format for E::C |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub throw { |
|
74
|
0
|
|
|
0
|
|
|
my $class = shift @_; |
|
75
|
0
|
|
|
|
|
|
my ( $msg, %params ) = _massage( @_ ); |
|
76
|
0
|
|
|
|
|
|
goto &Exception::Class::Base::throw( $class, message => $msg, %params ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _massage { |
|
80
|
0
|
|
|
0
|
|
|
my @items = @_; |
|
81
|
0
|
|
|
|
|
|
my %params = ( ref $items[-1] eq 'HASH' ) |
|
82
|
0
|
0
|
|
|
|
|
? %{ pop( @items ) } : (); |
|
83
|
0
|
|
|
|
|
|
my $msg = join( '', @items ); |
|
84
|
0
|
|
|
|
|
|
return ( $msg, %params ); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |