Exception: Ibex::LSP::ProtocolError

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

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.

RBS:

  • (String message, ?code: Integer, ?request_id: String | Integer | nil, ?fatal: bool) -> void

Parameters:

  • message (String)
  • code: (Integer) (defaults to: -32_600,)
  • request_id: (String, Integer, nil) (defaults to: nil)
  • fatal: (Boolean) (defaults to: false)


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

#codeInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


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

def code
  @code
end

#fatalBoolean (readonly)

Signature:

  • bool

Returns:

  • (Boolean)


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

def fatal
  @fatal
end

#request_idString, ... (readonly)

Signature:

  • String | Integer | nil

Returns:

  • (String, Integer, nil)


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

def request_id
  @request_id
end