JSON::RPC::Common::Procedure::Return::Version_1_1::Error - JSON-RPC 1.1 error class.


JSON-RPC-Common documentation Contained in the JSON-RPC-Common distribution.

Index


Code Index:

NAME

Top

JSON::RPC::Common::Procedure::Return::Version_1_1::Error - JSON-RPC 1.1 error class.

VERSION

Top

version 0.10

SYNOPSIS

Top

	my $return_with_error = $call->return_error("foo");

DESCRIPTION

Top

This class implements 1.1 error objects.

code and message are mandatory.

The data field is named error in the deflated version and name is set to JSONRPCError. How exciting.

See JSON::RPC::Common::Procedure::Return::Error.

AUTHOR

Top

Yuval Kogman <nothingmuch@woobling.org>

COPYRIGHT AND LICENSE

Top


JSON-RPC-Common documentation Contained in the JSON-RPC-Common distribution.

#!/usr/bin/perl

package JSON::RPC::Common::Procedure::Return::Version_1_1::Error;
BEGIN {
  $JSON::RPC::Common::Procedure::Return::Version_1_1::Error::VERSION = '0.10';
}
use Moose;
# ABSTRACT: JSON-RPC 1.1 error class.

use JSON::RPC::Common::TypeConstraints qw(JSONValue);

use namespace::clean -except => [qw(meta)];

extends qw(JSON::RPC::Common::Procedure::Return::Error);

has '+message' => (
	required => 1,
);

has '+code' => (
	default => 500,
);

has name => (
	is      => "rw",
	default => "JSONRPCError", # fucking idiots
);

sub deflate {
	my $self = shift;

	return {
		name    => $self->name,
		message => $self->message,
		code    => $self->code,
		( $self->has_data ? ( error => $self->data ) : () ),
	},
}

__PACKAGE__->meta->make_immutable;

__PACKAGE__




__END__