File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
lib/puppet_editor_services/protocol Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ def receive_json_message_as_string(content)
138138 def receive_json_message_as_hash ( json_obj )
139139 # There's no need to convert it to an object quite yet
140140 # Need to validate that this is indeed a valid message
141+ id = json_obj [ KEY_ID ]
141142 unless json_obj [ KEY_JSONRPC ] == JSONRPC_VERSION
142143 PuppetEditorServices . log_message ( :error , 'Invalid JSON RPC version' )
143144 reply_error id , CODE_INVALID_REQUEST , MSG_INVALID_REQ_JSONRPC
@@ -159,7 +160,6 @@ def receive_json_message_as_hash(json_obj)
159160 end
160161 end
161162
162- id = json_obj [ KEY_ID ]
163163 # Requests and Responses must have an ID that is either a string or integer
164164 if is_request || is_response
165165 unless id . is_a? ( String ) || id . is_a? ( Integer )
@@ -197,6 +197,10 @@ def receive_json_message_as_hash(json_obj)
197197 false
198198 end
199199
200+ def reply_error ( id , code , message )
201+ send_json_string ::PuppetEditorServices ::Protocol ::JsonRPCMessages . reply_error_by_id ( id , code , message ) . to_json
202+ end
203+
200204 # region Server-to-Client request/response methods
201205 def send_client_request ( rpc_method , params )
202206 request = ::PuppetEditorServices ::Protocol ::JsonRPCMessages . new_request ( client_request_id! , rpc_method , params )
Original file line number Diff line number Diff line change @@ -169,10 +169,14 @@ def self.reply_result(request, result)
169169 end
170170
171171 def self . reply_error ( request , code , message )
172+ reply_error_by_id ( request . id , code , message )
173+ end
174+
175+ def self . reply_error_by_id ( id , code , message )
172176 # Note - Strictly speaking the error should be typed object, however as this hidden behind
173177 # this method it's easier to just pass in a known hash construct
174178 ResponseMessage . new . from_h! (
175- 'id' => request . id ,
179+ 'id' => id ,
176180 'error' => {
177181 'code' => code ,
178182 'message' => message
You can’t perform that action at this time.
0 commit comments