lib/MojoX/JSON/RPC/Dispatcher/Method.pm

filter: Statementstmt 87.8% 29 / 33 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 8 / 10 Podpod 100% 9 / 9 totaltotal 87.5% 49 / 56 CC 3 SCAR 5.2
CC
3
Cov
86%
response
3.0
clear_error
2.0
internal_error
2.0
CRAP 1.7
« blib/lib/MojoX/JSON/RPC.pm ↑ Summary
1 package MojoX::JSON::RPC::Dispatcher::Method;
2  
3 3 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 3 has id => undef;
6 3 has method => undef;
7 3 has params => undef;
8 3 has result => undef;
9 3 has is_notification => 0;
10  
11 3 has error_code => undef;
12 3 has error_message => undef;
13 3 has error_data => undef;
14  
15 0 ▶sub clear_error {
Subroutine clear_error: not called CC=1 SCAR=6.9
Pod documented
16 0 my ($self) = @_;
17 0 return $self->error( undef, undef, undef );
18 }
19  
20 15 ▶sub error {
Subroutine error: called CC=1 SCAR=0.0
Pod documented
21 15 my ( $self, $code, $message, $data ) = @_;
22 15 $self->error_code($code);
23 15 $self->error_message($message);
24 15 $self->error_data($data);
25 15 return $self;
26 }
27  
28 89 ▶sub has_error {
Subroutine has_error: called CC=1 SCAR=0.0
Pod documented
29 89 my ($self) = @_;
30 89 return !!$self->error_code;
31 }
32  
33 0 ▶sub internal_error {
Subroutine internal_error: not called CC=1 SCAR=6.9
Pod documented
34 0 my ( $self, $msg ) = @_;
35 0 return $self->error( -32603, 'Internal error.', $msg );
36 }
37  
38 1 ▶sub invalid_params {
Subroutine invalid_params: called CC=1 SCAR=0.0
Pod documented
39 1 my ( $self, $msg ) = @_;
40 1 return $self->error( -32602, 'Invalid params.', $msg );
41 }
42  
43 10 ▶sub invalid_request {
Subroutine invalid_request: called CC=1 SCAR=0.0
Pod documented
44 10 my ( $self, $msg ) = @_;
45 10 return $self->error( -32600, 'Invalid Request.', $msg );
46 }
47  
48 2 ▶sub method_not_found {
Subroutine method_not_found: called CC=1 SCAR=0.0
Pod documented
49 2 my ( $self, $msg ) = @_;
50 2 return $self->error( -32601, 'Method not found.', $msg );
51 }
52  
53 2 ▶sub parse_error {
Subroutine parse_error: called CC=1 SCAR=0.0
Pod documented
54 2 my ( $self, $msg ) = @_;
55 2 return $self->error( -32700, 'Parse error.', $msg );
56 }
57  
58 40 ▶sub response {
Subroutine response: called CC=3 SCAR=11.1
Pod documented
59 40 my ($self) = @_;
60 return {
61 40 ▶ jsonrpc => '2.0',
Branch: 2 branches
BranchTrueFalseTotal
$self->is_notification ? : 0 40 40
$self->has_error ? : 15 25 40
62 $self->is_notification ? () : ( id => $self->id ),
63 $self->has_error
64 ? ( error => {
65 code => $self->error_code,
66 message => $self->error_message,
67 data => $self->error_data,
68 }
69 )
70 : ( result => $self->result )
71 };
72 }
73  
74 3 1;
75  
76 __END__
« blib/lib/MojoX/JSON/RPC.pm ↑ Summary