Class: PuppetEditorServices::Handler::JsonRPC

Inherits:
Base
  • Object
show all
Defined in:
lib/puppet_editor_services/handler/json_rpc.rb

Instance Attribute Summary

Attributes inherited from Base

#protocol

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PuppetEditorServices::Handler::Base

Instance Method Details

#handle(json_rpc_message, context = {}) ⇒ Object

context

request => original request


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/puppet_editor_services/handler/json_rpc.rb', line 20

def handle(json_rpc_message, context = {})
  case json_rpc_message

  when ::PuppetEditorServices::Protocol::JsonRPCMessages::RequestMessage
    return handle_request(json_rpc_message, context)

  when ::PuppetEditorServices::Protocol::JsonRPCMessages::NotificationMessage
    return handle_notification(json_rpc_message, context)

  when ::PuppetEditorServices::Protocol::JsonRPCMessages::ResponseMessage
    return handle_response(json_rpc_message, context)

  else
    PuppetEditorServices.log_message(:error, "Unknown JSON RPC message type #{json_rpc_message.class}")
  end
  false
end

#unhandled_exception(error, options) ⇒ Object

This method is abstract.

options

source        :request, :notification etc.
message       JSON Message that caused the error
error         Actual ruby error


14
15
16
# File 'lib/puppet_editor_services/handler/json_rpc.rb', line 14

def unhandled_exception(error, options)
  PuppetEditorServices.log_message(:error, "Unhandled exception from #{options[:source]}. JSON Message #{options[:message]}: #{error.inspect}\n#{error.backtrace}")
end