Exception: GroupDocsParserCloud::ApiError
- Inherits:
-
StandardError
- Object
- StandardError
- GroupDocsParserCloud::ApiError
- Defined in:
- lib/groupdocs_parser_cloud/api_error.rb
Overview
ApiError class for error handling
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
Instance Method Summary collapse
-
#initialize(arg = nil) ⇒ ApiError
constructor
Usage examples: ApiError.new ApiError.new(:code => 500, :response_body => “”).
Constructor Details
#initialize(arg = nil) ⇒ ApiError
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
31 32 33 |
# File 'lib/groupdocs_parser_cloud/api_error.rb', line 31 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
32 33 34 |
# File 'lib/groupdocs_parser_cloud/api_error.rb', line 32 def @message end |