line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Beekeeper::JSONRPC::Error; |
2
|
|
|
|
|
|
|
|
3
|
11
|
|
|
11
|
|
86
|
use strict; |
|
11
|
|
|
|
|
21
|
|
|
11
|
|
|
|
|
338
|
|
4
|
11
|
|
|
11
|
|
53
|
use warnings; |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
931
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
11
|
|
|
11
|
|
13000
|
use overload '""' => sub { $_[0]->{error}->{message} }; |
|
11
|
|
|
0
|
|
10343
|
|
|
11
|
|
|
|
|
94
|
|
|
0
|
|
|
|
|
0
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
2
|
|
|
2
|
1
|
17
|
my ($class, %args) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
bless { |
15
|
|
|
|
|
|
|
jsonrpc => '2.0', |
16
|
|
|
|
|
|
|
id => undef, |
17
|
|
|
|
|
|
|
error => { |
18
|
|
|
|
|
|
|
code => $args{code} || -32603, |
19
|
|
|
|
|
|
|
message => $args{message} || "Internal error", |
20
|
|
|
|
|
|
|
data => $args{data}, |
21
|
|
|
|
|
|
|
}, |
22
|
2
|
|
50
|
|
|
40
|
}, $class; |
|
|
|
50
|
|
|
|
|
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
0
|
1
|
0
|
sub id { $_[0]->{id} } |
26
|
7
|
|
|
7
|
1
|
38
|
sub message { $_[0]->{error}->{message} } |
27
|
7
|
|
|
7
|
1
|
51
|
sub code { $_[0]->{error}->{code} } |
28
|
1
|
|
|
1
|
1
|
6
|
sub data { $_[0]->{error}->{data} } |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
1
|
1027
|
sub success { 0 } |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
0
|
0
|
sub TO_JSON { return { %{$_[0]} } } |
|
0
|
|
|
|
|
0
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub parse_error { |
36
|
|
|
|
|
|
|
shift->new( |
37
|
0
|
|
|
0
|
0
|
0
|
code => -32700, |
38
|
|
|
|
|
|
|
message => "Parse error", |
39
|
|
|
|
|
|
|
data => "Invalid JSON was received by the server", |
40
|
|
|
|
|
|
|
@_ |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub invalid_request { |
45
|
|
|
|
|
|
|
shift->new( |
46
|
0
|
|
|
0
|
0
|
0
|
code => -32600, |
47
|
|
|
|
|
|
|
message => "Invalid request", |
48
|
|
|
|
|
|
|
data => "The JSON sent is not a valid request object.", |
49
|
|
|
|
|
|
|
@_ |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub request_timeout { |
54
|
|
|
|
|
|
|
shift->new( |
55
|
2
|
|
|
2
|
0
|
18
|
code => -31600, |
56
|
|
|
|
|
|
|
message => "Request timeout", |
57
|
|
|
|
|
|
|
@_ |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub request_not_authenticated { |
62
|
|
|
|
|
|
|
shift->new( |
63
|
0
|
|
|
0
|
0
|
|
code => -401, |
64
|
|
|
|
|
|
|
message => "Not logged in", |
65
|
|
|
|
|
|
|
data => "Request was not authenticated", |
66
|
|
|
|
|
|
|
@_ |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub request_not_authorized { |
71
|
|
|
|
|
|
|
shift->new( |
72
|
0
|
|
|
0
|
0
|
|
code => -403, |
73
|
|
|
|
|
|
|
message => "Request not authorized", |
74
|
|
|
|
|
|
|
data => "Request was not authorized", |
75
|
|
|
|
|
|
|
@_ |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub method_not_found { |
80
|
|
|
|
|
|
|
shift->new( |
81
|
0
|
|
|
0
|
0
|
|
code => -32601, |
82
|
|
|
|
|
|
|
message => "Method not found", |
83
|
|
|
|
|
|
|
data => "The method does not exist", |
84
|
|
|
|
|
|
|
@_ |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub method_not_available { |
89
|
|
|
|
|
|
|
shift->new( |
90
|
0
|
|
|
0
|
0
|
|
code => -31601, |
91
|
|
|
|
|
|
|
message => "Method not available", |
92
|
|
|
|
|
|
|
data => "The method is not available.", |
93
|
|
|
|
|
|
|
@_ |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub invalid_params { |
98
|
|
|
|
|
|
|
shift->new( |
99
|
0
|
|
|
0
|
1
|
|
code => -32602, |
100
|
|
|
|
|
|
|
message => "Invalid params", |
101
|
|
|
|
|
|
|
data => "Invalid method parameters.", |
102
|
|
|
|
|
|
|
@_ |
103
|
|
|
|
|
|
|
); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub internal_error { |
107
|
|
|
|
|
|
|
shift->new( |
108
|
0
|
|
|
0
|
0
|
|
code => -32603, |
109
|
|
|
|
|
|
|
message => "Internal error", |
110
|
|
|
|
|
|
|
data => "Internal JSON-RPC error.", |
111
|
|
|
|
|
|
|
@_ |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub server_error { |
116
|
|
|
|
|
|
|
shift->new( |
117
|
0
|
|
|
0
|
1
|
|
code => -32000, |
118
|
|
|
|
|
|
|
message => "Server error", |
119
|
|
|
|
|
|
|
@_ |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
1; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
__END__ |