File Coverage

blib/lib/SyForm/Exception/Role/WithOriginalError.pm
Criterion Covered Total %
statement 4 8 50.0
branch 0 4 0.0
condition n/a
subroutine 2 4 50.0
pod 0 2 0.0
total 6 18 33.3


line stmt bran cond sub pod time code
1             package SyForm::Exception::Role::WithOriginalError;
2             BEGIN {
3 1     1   970 $SyForm::Exception::Role::WithOriginalError::AUTHORITY = 'cpan:GETTY';
4             }
5             # ABSTRACT: Role for exceptions with a non SyForm error
6             $SyForm::Exception::Role::WithOriginalError::VERSION = '0.103';
7 1     1   6 use Moo::Role;
  1         13  
  1         5  
8              
9             has original_error => (
10             is => 'ro',
11             required => 1,
12             );
13              
14             sub rethrow_syform_exception {
15 0     0 0   my ( $class, $error ) = @_;
16 0 0         die $error if $error->isa('SyForm::Exception');
17             }
18              
19             sub error_message_text {
20 0     0 0   my ( $class, $error ) = @_;
21 0 0         my $error_type = $error->isa('Moose::Exception')
22             ? 'Moose exception' : 'Unknown error';
23             }
24              
25             around throw => sub {
26             my ( $orig, $class, $message, %args ) = @_;
27             $message .= "\n".'[Original Error] '.$args{original_error};
28             return $class->$orig($message, %args);
29             };
30              
31             1;
32              
33             __END__
34              
35             =pod
36              
37             =head1 NAME
38              
39             SyForm::Exception::Role::WithOriginalError - Role for exceptions with a non SyForm error
40              
41             =head1 VERSION
42              
43             version 0.103
44              
45             =head1 AUTHOR
46              
47             Torsten Raudssus <torsten@raudss.us>
48              
49             =head1 COPYRIGHT AND LICENSE
50              
51             This software is copyright (c) 2014 by Torsten Raudssus.
52              
53             This is free software; you can redistribute it and/or modify it under
54             the same terms as the Perl 5 programming language system itself.
55              
56             =cut