Core/Exception/ExceptionSerializer.pm untested

filter: Statementstmt 0.0% 0 / 33 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 1 SCAR 6.9
CC
1
Cov
0%
serialize
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Javonet::Core::Exception::ExceptionSerializer;
2 use strict;
3 use warnings FATAL => 'all';
4 use Moose;
5 use lib 'lib';
6 use aliased 'Javonet::Sdk::Core::PerlCommand' => 'PerlCommand';
7 use Try::Tiny;
8
9 sub serialize {
10 my ($self, $exception) = @_;
11 my $command;
12 try {
13 my $name = ref($exception);
14 my $message = $exception->get_message;
15 my $stack_trace = $exception->get_stack_trace;
16
17 $command = PerlCommand->new(
18 runtime => Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl'),
19 command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('Exception'),
20 payload => [ 0, undef, $name, $message, $stack_trace, undef, undef, undef ]
21 );
22 }
23 catch {
24 my $error = "Failed to serialize exception: $@";
25 $command = PerlCommand->new(
26 runtime => Javonet::Sdk::Core::RuntimeLib::get_runtime('Perl'),
27 command_type => Javonet::Sdk::Core::PerlCommandType::get_command_type('Exception'),
28 payload => [ 0, undef, 'SerializationError', $error, undef, undef, undef, undef ]
29 );
30 };
31 return $command
32
33 }
34
35 no Moose;
36 1;