File Coverage

blib/lib/Starch/Plugin/LogStoreExceptions.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Starch::Plugin::LogStoreExceptions;
2             our $VERSION = '0.14';
3              
4 8     8   5550 use Try::Tiny;
  8         19  
  8         604  
5              
6 8     8   53 use Moo::Role;
  8         17  
  8         67  
7 8     8   3270 use strictures 2;
  8         77  
  8         406  
8 8     8   1873 use namespace::clean;
  8         20  
  8         72  
9              
10             with 'Starch::Plugin::ForStore';
11              
12             foreach my $method (qw( set get remove )) {
13             around $method => sub{
14             my $orig = shift;
15             my $self = shift;
16              
17             my @args = @_;
18              
19             return try {
20             return $self->$orig( @args );
21             }
22             catch {
23             $self->log->errorf(
24             'Starch store %s errored when %s was called: %s',
25             $self->short_store_class_name(), $method, $_,
26             );
27             return {
28             $self->manager->no_store_state_key() => 1,
29             } if $method eq 'get';
30             return;
31             };
32             };
33             }
34              
35             1;
36             __END__