Articulate/Service/Error.pm

filter: Statementstmt 73.6% 14 / 19 Branchbran n/a Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 0.0% 0 / 1 totaltotal 58.0% 18 / 31 CC 3 SCAR 17.4
CC
3
Cov
61%
handle_error
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.7
« Articulate/Service/Simple.pm ↑ Summary Articulate/Routes/TransparentPreviews.pm »
1 package Articulate::Service::Error;
2  
3 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head1 NAME
7  
8 Articulate::Service::Error
9  
10 =DESCRIPTION
11  
12 Given request data like:
13  
14 {
15 error_type => 'Forbidden',
16 error => {}
17 }
18  
19 Creates an error with those attriutes and throws it. No access control is performed.
20  
21 Useful for when you want to throw an error from your route and serialise it.
22  
23 =cut
24  
25 6 ▶use Articulate::Syntax;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 6 with 'Articulate::Role::Service';
29  
30 sub handle_error {
31 0 ▶ my $self = shift;
Subroutine handle_error: not called CC=3 SCAR=24.8
Pod undocumented
32 0 my $request = shift;
33 0 ▶ my $error_type = $request->data->error_type // 'Internal';
Condition0%0/2
$request->data->error_type // "Internal"
l!l
00
MC/DC0%0/1
$request->data->error_type // "Internal"
$request->data->error_type
Truth table0%0/2
A
A= $request->data->error_type
Aresult
11
00
34 0 ▶ my $error_data = $request->data->error // {};
Condition0%0/2
$request->data->error // {}
l!l
00
MC/DC0%0/1
$request->data->error // {}
$request->data->error
Truth table0%0/2
A
A= $request->data->error
Aresult
11
00
35 0 throw_error $error_type, $error_data;
36 }
37  
38 6 1;
« Articulate/Service/Simple.pm ↑ Summary Articulate/Routes/TransparentPreviews.pm »