Class: Mindee::Parsing::V2::ErrorResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/parsing/v2/error_response.rb

Overview

Encapsulates information returned by the API when an error occurs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.

Parameters:

  • server_response (Hash)

    Raw JSON parsed into a Hash.



14
15
16
17
# File 'lib/mindee/parsing/v2/error_response.rb', line 14

def initialize(server_response)
  @status = server_response['status']
  @detail = server_response['detail']
end

Instance Attribute Details

#detailString (readonly)

Returns Error detail.

Returns:

  • (String)

    Error detail.



11
12
13
# File 'lib/mindee/parsing/v2/error_response.rb', line 11

def detail
  @detail
end

#statusInteger (readonly)

Returns HTTP status code.

Returns:

  • (Integer)

    HTTP status code.



9
10
11
# File 'lib/mindee/parsing/v2/error_response.rb', line 9

def status
  @status
end

Instance Method Details

#as_hashHash

Hash representation

Returns:

  • (Hash)

    Hash representation of the object.



27
28
29
30
31
32
# File 'lib/mindee/parsing/v2/error_response.rb', line 27

def as_hash
  {
    status: @status,
    detail: @detail,
  }
end

#to_sString

String representation.

Returns:

  • (String)


21
22
23
# File 'lib/mindee/parsing/v2/error_response.rb', line 21

def to_s
  "Error\n=====\n:Status: #{@status}\n:Detail: #{@detail}"
end