Exception: GQL::Error

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/gql/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg, code = 100, handle = nil) ⇒ Error

Returns a new instance of Error.



8
9
10
11
# File 'lib/gql/errors.rb', line 8

def initialize(msg, code = 100, handle = nil)
  @code, @handle = code, handle
  super(msg)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/gql/errors.rb', line 6

def code
  @code
end

#handleObject (readonly)

Returns the value of attribute handle.



6
7
8
# File 'lib/gql/errors.rb', line 6

def handle
  @handle
end

Instance Method Details

#as_jsonObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gql/errors.rb', line 13

def as_json
  result = {
    error: {
      code: code,
      type: self.class.name.split('::').last.titleize.downcase
    }
  }

  result[:error][:handle] = handle.to_s if handle
  result[:error][:message] = message if GQL.debug

  result
end