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   189763 use v5.28;
  30         122  
6 30     30   269 use strict;
  30         60  
  30         900  
7 30     30   136 use warnings;
  30         57  
  30         2511  
8              
9             our $VERSION = '0.33';
10              
11 30     30   661 use Iterator::Flex::Utils qw( :default REG_GENERAL REG_GP_ERROR );
  30         57  
  30         4961  
12 30     30   248 use Ref::Util;
  30         76  
  30         1448  
13              
14 30     30   586 use Role::Tiny;
  30         4587  
  30         200  
15 30     30   8412 use experimental 'signatures';
  30         70  
  30         207  
16              
17 30     30   5773 use namespace::clean;
  30         11169  
  30         238  
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34              
35 2     2 1 6 sub signal_error ( $self, $message = undef ) {
  2         3  
  2         3  
  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     3 my @message = ( $message // () );
40              
41 2 100       5 $exception->( @message ) if Ref::Util::is_coderef( $exception );
42              
43 1         345 require Iterator::Flex::Failure;
44 1         6 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__