File Coverage

blib/lib/Iterator/Flex/Role/Error/Throw.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 2 100.0
condition 1 3 33.3
subroutine 9 9 100.0
pod 1 1 100.0
total 46 48 95.8


line stmt bran cond sub pod time code
1             package Iterator::Flex::Role::Error::Throw;
2              
3             # ABSTRACT: signal error by throwing
4              
5 30     30   189987 use v5.28;
  30         91  
6 30     30   169 use strict;
  30         39  
  30         648  
7 30     30   95 use warnings;
  30         38  
  30         1995  
8              
9             our $VERSION = '0.34';
10              
11 30     30   490 use Iterator::Flex::Utils qw( :default REG_GENERAL REG_GP_ERROR );
  30         49  
  30         3648  
12 30     30   171 use Ref::Util;
  30         66  
  30         1061  
13              
14 30     30   561 use Role::Tiny;
  30         4908  
  30         174  
15 30     30   6223 use experimental 'signatures';
  30         70  
  30         162  
16              
17 30     30   4093 use namespace::clean;
  30         11962  
  30         182  
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35 2     2 1 7 sub signal_error ( $self, $message = undef ) {
  2         2  
  2         4  
  2         2  
36 2         8 $self->set_error;
37 2         4 my $exception = $REGISTRY{ refaddr $self }[REG_GENERAL][REG_GP_ERROR][1];
38              
39 2   33     4 my @message = ( $message // () );
40              
41 2 100       17 $exception->( @message ) if Ref::Util::is_coderef( $exception );
42              
43 1         349 require Iterator::Flex::Failure;
44 1         7 Iterator::Flex::Failure::Error->throw( @message );
45             }
46              
47              
48             1;
49              
50             #
51             # This file is part of Iterator-Flex
52             #
53             # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
54             #
55             # This is free software, licensed under:
56             #
57             # The GNU General Public License, Version 3, June 2007
58             #
59              
60             __END__