Exception: Keboola::GoodDataWriter::ResponseError

Inherits:
Error
  • Object
show all
Defined in:
lib/keboola/gooddata_writer/errors.rb

Direct Known Subclasses

ClientError, ServerError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ex, response = nil) ⇒ ResponseError


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/keboola/gooddata_writer/errors.rb', line 10

def initialize(ex, response = nil)
  @wrapped_exception, @response = nil, response

  if ex.respond_to?(:backtrace)
    super(ex.message)
    @wrapped_exception = ex

  elsif ex.respond_to?(:status_code)
    begin
      # try to parse response body to retreive more detailed API error message
      result = Parser.parse(ex.body)
      super("the server responded with status #{ex.status_code} and message '#{result['message']}'")
    rescue ParsingError
      super("the server responded with status #{ex.status_code}")
    ensure
      @response = ex
    end

  else
    super(ex.to_s)
  end
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response


8
9
10
# File 'lib/keboola/gooddata_writer/errors.rb', line 8

def response
  @response
end

Instance Method Details

#backtraceObject


33
34
35
# File 'lib/keboola/gooddata_writer/errors.rb', line 33

def backtrace
  @wrapped_exception ? @wrapped_exception.backtrace : super
end

#inspectObject


37
38
39
# File 'lib/keboola/gooddata_writer/errors.rb', line 37

def inspect
  %(#<#{self.class}: #{@wrapped_exception.class}>)
end