File Coverage

blib/lib/Data/Conveyor/Exception/Handler.pm
Criterion Covered Total %
statement 19 29 65.5
branch n/a
condition n/a
subroutine 7 12 58.3
pod 5 5 100.0
total 31 46 67.3


line stmt bran cond sub pod time code
1 1     1   758 use 5.008;
  1         4  
  1         111  
2 1     1   12 use strict;
  1         2  
  1         90  
3 1     1   7 use warnings;
  1         2  
  1         58  
4              
5             package Data::Conveyor::Exception::Handler;
6             BEGIN {
7 1     1   19 $Data::Conveyor::Exception::Handler::VERSION = '1.103130';
8             }
9              
10             # ABSTRACT: Stage-based conveyor-belt-like ticket handling system
11 1     1   5 use Data::Miscellany 'class_map';
  1         2  
  1         68  
12 1     1   6 use parent 'Class::Scaffold::Storable';
  1         4  
  1         7  
13 1         474 use constant ERRCODE_FOR_EXCEPTION_CLASS_HASH => (
14             UNIVERSAL => 'NC20000', # fallback
15 1     1   103 );
  1         2  
16              
17             sub RC_FOR_EXCEPTION_CLASS_HASH {
18 0     0 1   local $_ = $_[0]->delegate;
19 0           ( UNIVERSAL => $_->RC_INTERNAL_ERROR, # fallback
20             'Error::Hierarchy::Internal' => $_->RC_INTERNAL_ERROR,
21             'Class::Value::Exception' => $_->RC_ERROR,
22             'Class::Scaffold::Exception::Business' => $_->RC_ERROR,
23             'Data::Conveyor::Exception::Ticket' => $_->RC_INTERNAL_ERROR,
24             'Data::Conveyor::Exception::Ticket::MissingLock' => $_->RC_ERROR,
25             );
26             }
27              
28             sub STATUS_FOR_EXCEPTION_CLASS_HASH {
29 0     0 1   local $_ = $_[0]->delegate;
30 0           ( UNIVERSAL => $_->TS_ERROR, # fallback
31             'Error::Hierarchy::Internal' => $_->TS_ERROR,
32             'Class::Value::Exception' => $_->TS_RUNNING,
33             'Class::Scaffold::Exception::Business' => $_->TS_RUNNING,
34             'Data::Conveyor::Exception::Ticket' => $_->TS_ERROR,
35             'Data::Conveyor::Exception::Ticket::MissingLock' => $_->TS_RUNNING,
36             );
37             }
38              
39             sub errcode_for_exception_class {
40 0     0 1   my ($self, $class) = @_;
41 0           class_map(
42             $class,
43             scalar $self->every_hash(
44             'ERRCODE_FOR_EXCEPTION_CLASS_HASH',
45             'exception.errcode_for_class',
46             )
47             );
48             }
49              
50             sub rc_for_exception_class {
51 0     0 1   my ($self, $exception) = @_;
52              
53             # Here we don't use the payload item, but a subclass might use it to
54             # change the rc depending on the object type and command found in the
55             # payload item.
56 0           $self->delegate->make_obj(
57             'value_ticket_rc',
58             class_map(
59             $exception,
60             scalar $self->every_hash(
61             'RC_FOR_EXCEPTION_CLASS_HASH', 'exception.rc_for_class',
62             )
63             )
64             );
65             }
66              
67             sub status_for_exception_class {
68 0     0 1   my ($self, $exception) = @_;
69              
70             # Here we don't use the payload item, but a subclass might use it to
71             # change the status depending on the object type and command found in the
72             # payload item.
73 0           $self->delegate->make_obj(
74             'value_ticket_status',
75             class_map(
76             $exception,
77             scalar $self->every_hash(
78             'STATUS_FOR_EXCEPTION_CLASS_HASH',
79             'exception.status_for_class',
80             )
81             )
82             );
83             }
84             1;
85              
86              
87             __END__