File Coverage

blib/lib/RPC/Serialized/Exceptions.pm
Criterion Covered Total %
statement 35 39 89.7
branch 1 2 50.0
condition n/a
subroutine 11 14 78.5
pod 0 1 0.0
total 47 56 83.9


line stmt bran cond sub pod time code
1             #
2             # $HeadURL: https://svn.oucs.ox.ac.uk/people/oliver/pub/librpc-serialized-perl/trunk/lib/RPC/Serialized/Exceptions.pm $
3             # $LastChangedRevision: 1361 $
4             # $LastChangedDate: 2008-10-01 16:16:56 +0100 (Wed, 01 Oct 2008) $
5             # $LastChangedBy: oliver $
6             #
7             package RPC::Serialized::Exceptions;
8             {
9             $RPC::Serialized::Exceptions::VERSION = '1.123630';
10             }
11              
12 34     34   998 use strict;
  34         71  
  34         1296  
13 34     34   193 use warnings FATAL => 'all';
  34         62  
  34         1368  
14              
15 34     34   5247 use Symbol;
  34         5436  
  34         12024  
16             sub import {
17              
18             # Exception::Class looks at caller() to insert raise_error into that
19             # Namespace, so this hack means whoever use's us, they get a raise_error
20             # of their very own.
21              
22 80         465 *{Symbol::qualify_to_ref('throw_proto',caller())}
23 8     8   115 = sub { RPC::Serialized::X::Protocol->throw(@_) };
  80     80   391  
24              
25 80         565 *{Symbol::qualify_to_ref('throw_parse',caller())}
26 80     0   2307 = sub { RPC::Serialized::X::Parse->throw(@_) };
  0         0  
27              
28 80         303 *{Symbol::qualify_to_ref('throw_invalid',caller())}
29 80     0   1727 = sub { RPC::Serialized::X::Validation->throw(@_) };
  0         0  
30              
31 80         732 *{Symbol::qualify_to_ref('throw_system',caller())}
32 80     2   1619 = sub { RPC::Serialized::X::System->throw(@_) };
  2         265  
33              
34 80         340 *{Symbol::qualify_to_ref('throw_app',caller())}
35 80     19   1613 = sub { RPC::Serialized::X::Application->throw(@_) };
  19         3762  
36              
37 80         285 *{Symbol::qualify_to_ref('throw_authz',caller())}
38 80     0   1720 = sub { RPC::Serialized::X::Authorization->throw(@_) };
  0         0  
39              
40             # this is to quiesce Carp::carp which is called from within Data::Serializer
41             # and turn its output into Carp::croak.
42              
43 34     34   205 use Carp;
  34         87  
  34         2282  
44             {
45 34     34   169 no warnings 'redefine';
  34         90  
  34         7197  
  80         37542  
46             sub Carp::carp {
47 3 50   3 0 1240 die Carp::shortmess @_ if (caller)[0] =~ m/Data::Serializer/;
48 0           warn Carp::shortmess @_;
49             }
50             }
51             }
52              
53             use Exception::Class (
54 34         913 'RPC::Serialized::X',
55              
56             'RPC::Serialized::X::Protocol',
57             { isa => 'RPC::Serialized::X',
58             description => 'RPC protocol error',
59             alias => 'throw_proto',
60             },
61              
62             'RPC::Serialized::X::Parse',
63             { isa => 'RPC::Serialized::X',
64             description => 'Data::Serializer parse error',
65             alias => 'throw_parse',
66             },
67              
68             'RPC::Serialized::X::Validation',
69             { isa => 'RPC::Serialized::X',
70             description => 'Data validation error',
71             alias => 'throw_invalid',
72             },
73              
74             'RPC::Serialized::X::System',
75             { isa => 'RPC::Serialized::X',
76             description => 'System error',
77             alias => 'throw_system',
78             },
79              
80             'RPC::Serialized::X::Application',
81             { isa => 'RPC::Serialized::X',
82             description => 'Application programming error',
83             alias => 'throw_app',
84             },
85              
86             'RPC::Serialized::X::Authorization',
87             { isa => 'RPC::Serialized::X',
88             description => 'Authorization failed',
89             alias => 'throw_authz',
90             }
91              
92 34     34   30812 );
  34         336385  
93              
94             1;
95