Exception: Msf::RPC::JSON::RpcError
- Inherits:
-
StandardError
- Object
- StandardError
- Msf::RPC::JSON::RpcError
- Defined in:
- lib/msf/core/rpc/json/error.rb
Overview
Base class for all Msf::RPC::JSON exceptions.
Direct Known Subclasses
InternalError, InvalidParams, InvalidRequest, MethodNotFound, ParseError, ServerError
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Code Message Meaning -32700 Parse error Invalid JSON was received by the server.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(code, message, data: nil) ⇒ RpcError
constructor
Instantiate an RpcError object.
- #to_h ⇒ Object
Constructor Details
#initialize(code, message, data: nil) ⇒ RpcError
Instantiate an RpcError object.
51 52 53 54 55 56 |
# File 'lib/msf/core/rpc/json/error.rb', line 51 def initialize(code, , data: nil) super() @code = code @message = @data = data end |
Instance Attribute Details
#code ⇒ Object (readonly)
Code Message Meaning -32700 Parse error Invalid JSON was received by the server. An error
occurred on the server while parsing the JSON text.
-32600 Invalid Request The JSON sent is not a valid Request object. -32601 Method not found The method does not exist / is not available. -32602 Invalid params Invalid method parameter(s). -32603 Internal error Internal JSON-RPC error. -32000 to -32099 Server error Reserved for implementation-defined server-errors.
38 39 40 |
# File 'lib/msf/core/rpc/json/error.rb', line 38 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
40 41 42 |
# File 'lib/msf/core/rpc/json/error.rb', line 40 def data @data end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
39 40 41 |
# File 'lib/msf/core/rpc/json/error.rb', line 39 def @message end |
Instance Method Details
#to_h ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/msf/core/rpc/json/error.rb', line 58 def to_h hash = { code: @code, message: @message } # process data member unless @data.nil? if @data.is_a?(String) || @data.kind_of?(Numeric) || @data.is_a?(Array) || @data.is_a?(Hash) hash[:data] = @data elsif @data.respond_to?(:to_h) hash[:data] = @data.to_h else hash[:data] = @data.to_s end end hash end |