Exception: Mindee::Errors::MindeeHTTPErrorV2

Inherits:
MindeeError
  • Object
show all
Defined in:
lib/mindee/errors/mindee_http_error_v2.rb

Overview

API V2 HttpError

Direct Known Subclasses

MindeeHTTPUnknownErrorV2

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_error) ⇒ MindeeHTTPErrorV2

Returns a new instance of MindeeHTTPErrorV2.

Parameters:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mindee/errors/mindee_http_error_v2.rb', line 22

def initialize(http_error)
  if http_error.is_a?(Parsing::V2::ErrorResponse)
    http_error = { 'detail' => http_error.detail,
                   'status' => http_error.status,
                   'title' => http_error.title,
                   'code' => http_error.code,
                   'errors' => http_error.errors }
  end
  @status = http_error['status']
  @detail = http_error['detail']
  @title = http_error['title']
  @code = http_error['code']
  @errors = if http_error.key?('errors')
              http_error['errors'].map do |error|
                Parsing::V2::ErrorItem.new(error)
              end
            else
              []
            end
  super("HTTP #{@status} - #{@title} :: #{@code} - #{@detail}")
end

Instance Attribute Details

#codeString (readonly)

Returns A machine-readable code specific to the occurrence of the problem.

Returns:

  • (String)

    A machine-readable code specific to the occurrence of the problem.



17
18
19
# File 'lib/mindee/errors/mindee_http_error_v2.rb', line 17

def code
  @code
end

#detailString (readonly)

Returns A human-readable explanation specific to the occurrence of the problem.

Returns:

  • (String)

    A human-readable explanation specific to the occurrence of the problem.



13
14
15
# File 'lib/mindee/errors/mindee_http_error_v2.rb', line 13

def detail
  @detail
end

#errorsArray<ErrorItem> (readonly)

Returns A list of explicit error details.

Returns:

  • (Array<ErrorItem>)

    A list of explicit error details.



19
20
21
# File 'lib/mindee/errors/mindee_http_error_v2.rb', line 19

def errors
  @errors
end

#statusInteger (readonly)

Returns The HTTP status code returned by the server.

Returns:

  • (Integer)

    The HTTP status code returned by the server.



11
12
13
# File 'lib/mindee/errors/mindee_http_error_v2.rb', line 11

def status
  @status
end

#titleString (readonly)

Returns A short, human-readable summary of the problem.

Returns:

  • (String)

    A short, human-readable summary of the problem.



15
16
17
# File 'lib/mindee/errors/mindee_http_error_v2.rb', line 15

def title
  @title
end