Exception: Ibex::LSP::ProtocolError

Inherits:
Error
  • Object
show all
Defined in:
lib/ibex/lsp/protocol_error.rb

Overview

Bounded protocol and workspace failures with their JSON-RPC error code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, code: -32_600,, request_id: nil, fatal: false) ⇒ ProtocolError

Returns a new instance of ProtocolError.



22
23
24
25
26
27
28
29
30
# File 'lib/ibex/lsp/protocol_error.rb', line 22

def initialize(message, code: -32_600, request_id: nil, fatal: false)
  normalized = message.encode(Encoding::UTF_8, invalid: :replace, undef: :replace)
  bounded = normalized[0, Limits::MAX_ERROR_MESSAGE_CHARACTERS] || ""
  bounded += "" if bounded.length < normalized.length
  super("(lsp):1:1: #{bounded}")
  @code = code
  @request_id = request_id
  @fatal = fatal
end

Instance Attribute Details

#codeObject (readonly)

: Integer



17
18
19
# File 'lib/ibex/lsp/protocol_error.rb', line 17

def code
  @code
end

#fatalObject (readonly)

: bool



19
20
21
# File 'lib/ibex/lsp/protocol_error.rb', line 19

def fatal
  @fatal
end

#request_idObject (readonly)

: String | Integer | nil



18
19
20
# File 'lib/ibex/lsp/protocol_error.rb', line 18

def request_id
  @request_id
end