Class: JsonRpcObjects::V20::Error

Overview

Error description object class for Response.

Constant Summary collapse

VERSION =

Holds link to its version module.

JsonRpcObjects::V20
DATA_MEMBER_NAME =

Indicates data member name.

:data

Instance Attribute Summary

Attributes inherited from JsonRpcObjects::V11::WD::Error

#code, #data, #message

Attributes included from JsonRpcObjects::V11::WD::Extensions

#extensions

Attributes inherited from JsonRpcObjects::V10::Error

#data

Attributes inherited from Generic::Object

#serializer

Instance Method Summary collapse

Methods inherited from JsonRpcObjects::V11::WD::Error

create

Methods included from JsonRpcObjects::V11::WD::Extensions

#[], #[]=, #method_missing

Methods inherited from JsonRpcObjects::V10::Error

create

Methods inherited from Generic::Object

create, #initialize, parse, #serialize, #to_json, version

Constructor Details

This class inherits a constructor from JsonRpcObjects::Generic::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JsonRpcObjects::V11::WD::Extensions

Instance Method Details

#check!Object

Checks correctness of the data.



42
43
44
45
46
47
48
49
50
# File 'lib/json-rpc-objects/v20/error.rb', line 42

def check!
    self.normalize!

    if ((-32768..-32000).include?(@code)) and not ((@code == -32700) or
         ((-32603..-32600).include?(@code)) or ((-32099..-32000).include?(code)))

        raise JsonRpcObjects::Exceptions::InvalidCode::new("Code is invalid because of reserved space.")
    end
end

#outputHash

Renders data to output hash.

Returns:

  • (Hash)

    with data of error



57
58
59
60
61
62
63
64
65
66
# File 'lib/json-rpc-objects/v20/error.rb', line 57

def output
    result = super()
    
    if result.include? "error"
        result["data"] = result["error"]
        result.delete("error")
    end

    return result
end