Sha256: 324471a6b2722783f19e3e62a366821346cc29670d316874fd864b68536543a8

Contents?: true

Size: 1.87 KB

Versions: 1

Compression:

Stored size: 1.87 KB

Contents

# encoding: utf-8
# (c) 2011 Martin Kozák (martinkozak@martinkozak.net)

require "qrpc/general"
require "qrpc/protocol/abstract/error"
require "qrpc/protocol/json-rpc/native/exception-data"

##
# General QRPC module.
#

module QRPC
    
    ##
    # Protocols helper module.
    # @since 0.9.0
    #
    
    module Protocol

        ##
        # JSON-RPC protocol implementation.
        # @since 0.9.0
        #
        
        class JsonRpc
        
            ##
            # JSON-RPC error implementation.
            # @since 0.9.0
            #
            
            class Error < QRPC::Protocol::Abstract::Error
              
                ##
                # Holds native object.
                #
                
                @native 
                
                ##
                # Returns the native object.
                # @return [JsonRpcObjects::Generic::Error]  native response object
                #
                
                def native
                    if @native.nil?
                        exception = @options.exception
                        request = @options.request
                        data = QRPC::Protocol::JsonRpc::Native::ExceptionData::create(exception)
                        
                        @native = request.native.class::version.error::create(100, "exception raised during processing the request", :error => data.output)
                        @native.serializer = @options.serializer
                    end
                    
                    @native
                end
                
                ##
                # Serializes object to the resultant form.
                # @return [String]  serialized form
                #
                
                def serialize
                    self.native.serialize
                end
                                
            end
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qrpc-0.9.0 lib/qrpc/protocol/json-rpc/error.rb