Class: ShellEv::InternalServerErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/shell_ev/exceptions/internal_server_error_exception.rb

Overview

InternalServerError class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ InternalServerErrorException

The constructor.

Parameters:

  • The (String)

    reason for raising an exception.

  • The (HttpResponse)

    HttpReponse of the API call.



32
33
34
35
36
# File 'lib/shell_ev/exceptions/internal_server_error_exception.rb', line 32

def initialize(reason, response)
  super(reason, response)
  hash = APIHelper.json_deserialize(@response.raw_body)
  unbox(hash)
end

Instance Attribute Details

#detailsArray[String]

Exception details of the error

Returns:

  • (Array[String])


27
28
29
# File 'lib/shell_ev/exceptions/internal_server_error_exception.rb', line 27

def details
  @details
end

#errorsArray[InternalErrorObject]

Exception details of the error

Returns:



23
24
25
# File 'lib/shell_ev/exceptions/internal_server_error_exception.rb', line 23

def errors
  @errors
end

#request_idString

requestId is unique identifier value that is attached to requests and messages that allow reference to a particular transaction or event chain.

Returns:

  • (String)


15
16
17
# File 'lib/shell_ev/exceptions/internal_server_error_exception.rb', line 15

def request_id
  @request_id
end

#statusString

Status of the request

Returns:

  • (String)


19
20
21
# File 'lib/shell_ev/exceptions/internal_server_error_exception.rb', line 19

def status
  @status
end

Instance Method Details

#unbox(hash) ⇒ Object

Populates this object by extracting properties from a hash. response body.

Parameters:

  • The (Hash)

    deserialized response sent by the server in the



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/shell_ev/exceptions/internal_server_error_exception.rb', line 41

def unbox(hash)
  @request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
  @status = hash.key?('status') ? hash['status'] : SKIP
  # Parameter is an array, so we need to iterate through it
  @errors = nil
  unless hash['errors'].nil?
    @errors = []
    hash['errors'].each do |structure|
      @errors << (InternalErrorObject.from_hash(structure) if structure)
    end
  end

  @errors = SKIP unless hash.key?('errors')
  @details = hash.key?('details') ? hash['details'] : SKIP
end