Class: TqlOtrFactoringDataExchange::ProblemDetailsErrorException

Inherits:
APIException
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb

Overview

[RFC 7807](datatracker.ietf.org/doc/html/rfc7807) Problem Details response returned for validation errors and other non-success outcomes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reason, response) ⇒ ProblemDetailsErrorException

The constructor.

Parameters:

  • reason (String)

    The reason for raising an exception.

  • response (HttpResponse)

    The HttpReponse of the API call.



28
29
30
31
32
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 28

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

Instance Attribute Details

#detailString

Detailed, human-readable explanation specific to this occurrence.

Returns:

  • (String)


23
24
25
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 23

def detail
  @detail
end

#statusInteger

HTTP status code.

Returns:

  • (Integer)


19
20
21
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 19

def status
  @status
end

#titleString

Short, human-readable summary of the problem type.

Returns:

  • (String)


15
16
17
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 15

def title
  @title
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



52
53
54
55
56
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 52

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} title: #{@title.inspect}, status: #{@status.inspect}, detail:"\
  " #{@detail.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



46
47
48
49
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 46

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} title: #{@title}, status: #{@status}, detail: #{@detail}>"
end

#unbox(hash) ⇒ Object

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

Parameters:

  • hash (Hash)

    The deserialized response sent by the server in the



37
38
39
40
41
42
43
# File 'lib/tql_otr_factoring_data_exchange/exceptions/problem_details_error_exception.rb', line 37

def unbox(hash)
  return nil unless hash

  @title = hash.key?('title') ? hash['title'] : SKIP
  @status = hash.key?('status') ? hash['status'] : SKIP
  @detail = hash.key?('detail') ? hash['detail'] : SKIP
end