Exception: Msf::RPC::JSON::ErrorResponse
- Inherits:
-
ClientError
- Object
- StandardError
- ClientError
- Msf::RPC::JSON::ErrorResponse
- Defined in:
- lib/msf/core/rpc/json/error.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Attributes inherited from ClientError
Class Method Summary collapse
-
.parse(response, symbolize_names: true) ⇒ ErrorResponse
Parse response and return a new ErrorResponse instance.
Instance Method Summary collapse
-
#initialize(id:, code:, message:, data: nil, response: nil) ⇒ ErrorResponse
constructor
Instantiate an ErrorResponse object.
Constructor Details
#initialize(id:, code:, message:, data: nil, response: nil) ⇒ ErrorResponse
Instantiate an ErrorResponse object.
218 219 220 221 222 223 224 |
# File 'lib/msf/core/rpc/json/error.rb', line 218 def initialize(id:, code:, message:, data: nil, response: nil) super(, response: response) @id = id @code = code @message = @data = data end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
173 174 175 |
# File 'lib/msf/core/rpc/json/error.rb', line 173 def code @code end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
175 176 177 |
# File 'lib/msf/core/rpc/json/error.rb', line 175 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
172 173 174 |
# File 'lib/msf/core/rpc/json/error.rb', line 172 def id @id end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
174 175 176 |
# File 'lib/msf/core/rpc/json/error.rb', line 174 def @message end |
Class Method Details
.parse(response, symbolize_names: true) ⇒ ErrorResponse
Parse response and return a new ErrorResponse instance.
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/msf/core/rpc/json/error.rb', line 182 def self.parse(response, symbolize_names: true) id_key = symbolize_names ? :id : :id.to_s error_key = symbolize_names ? :error : :error.to_s code_key = symbolize_names ? :code : :code.to_s = symbolize_names ? :message : :message.to_s data_key = symbolize_names ? :data : :data.to_s id = response[id_key] error = response[error_key] if !error.nil? code = error[code_key] = error[] data = error[data_key] else code = nil = nil data = nil end ErrorResponse.new(id: id, code: code, message: , data: data, response: response) end |