Class: LanguageServer::Protocol::Interface::ResponseError

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/response_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, message:, data: nil) ⇒ ResponseError

Returns a new instance of ResponseError.



5
6
7
8
9
10
11
12
13
# File 'lib/language_server/protocol/interface/response_error.rb', line 5

def initialize(code:, message:, data: nil)
  @attributes = {}

  @attributes[:code] = code
  @attributes[:message] = message
  @attributes[:data] = data if data

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



40
41
42
# File 'lib/language_server/protocol/interface/response_error.rb', line 40

def attributes
  @attributes
end

Instance Method Details

#codenumber

A number indicating the error type that occurred.

Returns:

  • (number)


19
20
21
# File 'lib/language_server/protocol/interface/response_error.rb', line 19

def code
  attributes.fetch(:code)
end

#dataany

A primitive or structured value that contains additional information about the error. Can be omitted.

Returns:

  • (any)


36
37
38
# File 'lib/language_server/protocol/interface/response_error.rb', line 36

def data
  attributes.fetch(:data)
end

#messagestring

A string providing a short description of the error.

Returns:

  • (string)


27
28
29
# File 'lib/language_server/protocol/interface/response_error.rb', line 27

def message
  attributes.fetch(:message)
end

#to_hashObject



42
43
44
# File 'lib/language_server/protocol/interface/response_error.rb', line 42

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



46
47
48
# File 'lib/language_server/protocol/interface/response_error.rb', line 46

def to_json(*args)
  to_hash.to_json(*args)
end