line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoX::JSON::RPC::Dispatcher::Method; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
15
|
use Mojo::Base -base; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
15
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has id => undef; |
6
|
|
|
|
|
|
|
has method => undef; |
7
|
|
|
|
|
|
|
has params => undef; |
8
|
|
|
|
|
|
|
has result => undef; |
9
|
|
|
|
|
|
|
has is_notification => 0; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has error_code => undef; |
12
|
|
|
|
|
|
|
has error_message => undef; |
13
|
|
|
|
|
|
|
has error_data => undef; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub clear_error { |
16
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
17
|
0
|
|
|
|
|
0
|
return $self->error( undef, undef, undef ); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub error { |
21
|
15
|
|
|
15
|
1
|
29
|
my ( $self, $code, $message, $data ) = @_; |
22
|
15
|
|
|
|
|
32
|
$self->error_code($code); |
23
|
15
|
|
|
|
|
86
|
$self->error_message($message); |
24
|
15
|
|
|
|
|
78
|
$self->error_data($data); |
25
|
15
|
|
|
|
|
72
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub has_error { |
29
|
89
|
|
|
89
|
1
|
296
|
my ($self) = @_; |
30
|
89
|
|
|
|
|
127
|
return !!$self->error_code; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub internal_error { |
34
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $msg ) = @_; |
35
|
0
|
|
|
|
|
0
|
return $self->error( -32603, 'Internal error.', $msg ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub invalid_params { |
39
|
1
|
|
|
1
|
1
|
8
|
my ( $self, $msg ) = @_; |
40
|
1
|
|
|
|
|
4
|
return $self->error( -32602, 'Invalid params.', $msg ); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub invalid_request { |
44
|
10
|
|
|
10
|
1
|
58
|
my ( $self, $msg ) = @_; |
45
|
10
|
|
|
|
|
41
|
return $self->error( -32600, 'Invalid Request.', $msg ); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub method_not_found { |
49
|
2
|
|
|
2
|
1
|
11
|
my ( $self, $msg ) = @_; |
50
|
2
|
|
|
|
|
4
|
return $self->error( -32601, 'Method not found.', $msg ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub parse_error { |
54
|
2
|
|
|
2
|
1
|
14
|
my ( $self, $msg ) = @_; |
55
|
2
|
|
|
|
|
6
|
return $self->error( -32700, 'Parse error.', $msg ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub response { |
59
|
40
|
|
|
40
|
1
|
60
|
my ($self) = @_; |
60
|
|
|
|
|
|
|
return { |
61
|
40
|
50
|
|
|
|
64
|
jsonrpc => '2.0', |
|
|
100
|
|
|
|
|
|
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
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |