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
# File 'lib/json-rpc-objects/v20/error.rb', line 42

def check!
    self.normalize!

    if (@code.in? -32768..-32000) and not ((@code == -32700) or (@code.in? -32603..-32600) or (@code.in? -32099..-32000))
        raise Exception::new("Code is invalid because of reserved space.")
    end
end

#outputHash

Renders data to output hash.

Returns:

  • (Hash)

    with data of error



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

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

    return result
end