| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package JSON::RPC::Common::Procedure::Return::Error; | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | $JSON::RPC::Common::Procedure::Return::Error::VERSION = '0.11'; | |||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Base class for JSON-RPC errors | ||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use JSON::RPC::Common::TypeConstraints qw(JSONValue); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use namespace::clean -except => [qw(meta)]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | sub new_dwim { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_dwim: called CC=4 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | if ( @args == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | if ( blessed($args[0]) and $args[0]->isa($class) ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($args[0]) and $args[0]->isa($class)
MC/DC0%0/2
builtin::blessed($args[0]) and $args[0]->isa($class)
builtin::blessed($args[0])
$args[0]->isa($class)
Truth table0%0/3
A and B
A= builtin::blessed($args[0])B= $args[0]->isa($class)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | return $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | $class->inflate(@args); | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | ▶ | sub inflate { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inflate: called CC=10 SCAR=23.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 4 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | if (@args == 1 and defined $args[0] and (ref($args[0])||'') eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition62%5/8
@args == 1 and defined $args[0] and (ref $args[0] || "") eq "HASH"
@args == 1 and defined $args[0]
ref $args[0] || ''
MC/DC33%1/3
@args == 1 and defined $args[0] and (ref $args[0] || "") eq "HASH"
@args == 1
defined $args[0]
ref $args[0]
Truth table50%2/4
A and B and C
A= @args == 1B= defined $args[0]C= ref $args[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | $data = { %{ $args[0] } }; | |||||||||||||||||||||||||||||||||||||||||||||
| 30 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | if ( @args % 2 == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | unshift @args, "message"; | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | $data = { @args }; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | my %constructor_args; | |||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 4 | foreach my $arg ( qw(message code) ) { | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 8 | ▶ | $constructor_args{$arg} = delete $data->{$arg} if exists $data->{$arg}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | ▶ | if ( keys %$data ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | $constructor_args{data} = (join(" ", keys %$data) eq 'data' ? $data->{data} : $data); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 4 | $class->new(%constructor_args); | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 6 | has data => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | isa => JSONValue, | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||
| 52 | predicate => "has_data", | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | has message => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | isa => "Str", | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | predicate => "has_message", | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | has code => ( | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | isa => "Int", | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | is => "rw", | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | predicate => "has_code", | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # FIXME delegate to a dictionary | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | ▶ | sub http_status { 500 } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
http_status: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 6 | __PACKAGE__->meta->make_immutable(); | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 6 | __PACKAGE__ | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||