Exception: NotepadqqApi::MessageInterpreterError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/notepadqq_api/message_interpreter.rb

Defined Under Namespace

Modules: ErrorCode

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error_code, error_string) ⇒ MessageInterpreterError

Returns a new instance of MessageInterpreterError.



132
133
134
135
# File 'lib/notepadqq_api/message_interpreter.rb', line 132

def initialize(error_code, error_string)
  @error_code = error_code
  @error_string = error_string
end

Instance Attribute Details

#error_codeObject (readonly)

Returns the value of attribute error_code.



129
130
131
# File 'lib/notepadqq_api/message_interpreter.rb', line 129

def error_code
  @error_code
end

#error_stringObject (readonly)

Returns the value of attribute error_string.



130
131
132
# File 'lib/notepadqq_api/message_interpreter.rb', line 130

def error_string
  @error_string
end

Instance Method Details

#descriptionObject



137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/notepadqq_api/message_interpreter.rb', line 137

def description
  str_code =
    case @error_code
      when ErrorCode::NONE then "None"
      when ErrorCode::INVALID_REQUEST then "Invalid request"
      when ErrorCode::INVALID_ARGUMENT_NUMBER then "Invalid argument number"
      when ErrorCode::INVALID_ARGUMENT_TYPE then "Invalid argument type"
      when ErrorCode::OBJECT_DEALLOCATED then "Object deallocated"
      when ErrorCode::OBJECT_NOT_FOUND then "Object not found"
      when ErrorCode::METHOD_NOT_FOUND then "Method not found"
      else "Unknown error"
    end

  unless @error_string.nil? || @error_string.empty?
    str_code += ': ' + @error_string
  end

  str_code
end