Core/Exception/ExceptionThrower.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 56 CC 2 SCAR 10.3
CC
2
Cov
0%
throwException
6.0
create_stack_trace
2.0
BEGIN
2.0
CRAP 2.8
1 package Javonet::Core::Exception::ExceptionThrower;
2 use strict;
3 use warnings FATAL => 'all';
4 use Moose;
5 use Nice::Try;
6 use aliased 'Javonet::Core::Exception::Exception' => 'Exception';
7 use lib 'lib';
8
9
10 sub throwException {
11 my ($self, $exception_command) = @_;
12 my $exception_name = $exception_command->{payload}[2];
13 my $exception_message =$exception_name . "\n " . $exception_command->{payload}[3];
14 my $stack_trace = "";
15 if (defined($exception_command->{payload}[4])){
16 $stack_trace = create_stack_trace($exception_command->{payload}[4], $exception_command->{payload}[5], $exception_command->{payload}[6], $exception_command->{payload}[7]);
17 }
18 my $exception_msg = $exception_name . " \n " . $exception_message . " \n " .$stack_trace;
19 die $exception_msg;
20 }
21
22 sub create_stack_trace {
23 my ($stack_trace_classes, $stack_trace_methods, $stack_trace_lines, $stack_trace_files) = @_;
24 my @classes = split /\|/, $stack_trace_classes;
25 my @methods = split /\|/, $stack_trace_methods;
26 my @lines = split /\|/, $stack_trace_lines;
27 my @files = split /\|/, $stack_trace_files;
28
29 my $stack_trace = "";
30 for (my $i = 0; $i < scalar(@classes); $i++) {
31 $stack_trace .= " at $methods[$i] ";
32 $stack_trace .= "($files[$i] line $lines[$i])";
33 $stack_trace .= "\n";
34 }
35
36 return $stack_trace;
37 }
38
39 no Moose;
40 1;