Exception: GroupDocsParserCloud::ApiError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/groupdocs_parser_cloud/api_error.rb

Overview

ApiError class for error handling

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(arg = nil) ⇒ ApiError

Usage examples:

ApiError.new
ApiError.new(:code => 500, :response_body => "")


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/groupdocs_parser_cloud/api_error.rb', line 37

def initialize(arg = nil)
  if arg.is_a? Hash
    
    if arg.key?(:response_body)
      data = JSON.parse(arg[:response_body], :symbolize_names => true)
      if !data.nil?
        if !data[:error].nil?
          if data[:error].is_a? String
            @message = data[:error]
          elsif !data[:error][:message].nil?
            @message = data[:error][:message]
          end
        elsif !data[:Error].nil? && !data[:Error][:Message].nil?
          @message = data[:Error][:Message]
        elsif !data[:message].nil?
          @message = data[:message]
        end
end
    end

    if arg.key?(:arg) then
      @code = arg[:Code]
    end
    
  else
    super arg
  end
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



31
32
33
# File 'lib/groupdocs_parser_cloud/api_error.rb', line 31

def code
  @code
end

#messageObject (readonly)

Returns the value of attribute message.



32
33
34
# File 'lib/groupdocs_parser_cloud/api_error.rb', line 32

def message
  @message
end