Server/Error.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 19 / 19 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Server.pm ↑ Summary
1 package Catalyst::Plugin::JSONRPC::Server::Error;
2 8 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 our $VERSION = '0.003';
7  
8 8 has code => ( is => 'ro', required => 1 );
9 8 has message => ( is => 'ro', required => 1 );
10 8 has data => ( is => 'ro' );
11  
12 1 ▶sub throw ( $class, %args ) {
Subroutine throw: called CC=1 SCAR=0.0
Pod documented
13 1 die $class->new(%args);
14 }
15  
16 =head1 NAME
17  
18 Catalyst::Plugin::JSONRPC::Server::Error - a structured JSON-RPC error
19  
20 =head1 DESCRIPTION
21  
22 A handler may throw one of these to return a specific JSON-RPC error from
23 L<Catalyst::Plugin::JSONRPC::Server::Dispatcher>.
24  
25 =head1 ATTRIBUTES
26  
27 =head2 code
28  
29 Required. The JSON-RPC error code (an integer). The spec reserves -32768 through
30 -32000 for pre-defined errors, of which -32099 through -32000 are set aside for
31 implementation-defined server errors. Codes outside the reserved block are free
32 for application-defined errors.
33  
34 =head2 message
35  
36 Required. A short, single-sentence description of the error.
37  
38 =head2 data
39  
40 Optional. Any additional information about the error, as a JSON-serializable
41 value. Omitted from the response envelope entirely when not set.
42  
43 =head1 METHODS
44  
45 =head2 throw( code => $n, message => $str, data => $any )
46  
47 Convenience constructor that C<die>s a new instance.
48  
49 =cut
50  
51 8 1;
« Server.pm ↑ Summary