Exception: Mints::Errors::ServiceError

Inherits:
RuntimeError
  • Object
show all
Defined in:
lib/errors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, title, detail, http_status, response) ⇒ ServiceError

Returns a new instance of ServiceError.

Parameters:

  • client (Client)
  • title (String)
  • detail (String)
  • http_status (Integer)
  • response (String Object Array)

42
43
44
45
46
47
48
49
50
# File 'lib/errors.rb', line 42

def initialize(client, title, detail, http_status, response)
  @title = title
  @client = client
  @response = response
  @http_status = http_status
  @detail = detail && !detail.empty? ? detail : self.class.to_s

  super(@detail)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.


73
74
75
# File 'lib/errors.rb', line 73

def client
  @client
end

#detailString (readonly)

Returns:

  • (String)

53
54
55
# File 'lib/errors.rb', line 53

def detail
  @detail
end

#http_statusObject (readonly)

Returns the value of attribute http_status.


73
74
75
# File 'lib/errors.rb', line 73

def http_status
  @http_status
end

#responseObject (readonly)

Returns the value of attribute response.


73
74
75
# File 'lib/errors.rb', line 73

def response
  @response
end

#titleObject (readonly)

Returns the value of attribute title.


73
74
75
# File 'lib/errors.rb', line 73

def title
  @title
end

Instance Method Details

#to_h(extra_fields = {}) ⇒ Object


57
58
59
60
61
62
63
64
65
66
67
# File 'lib/errors.rb', line 57

def to_h(extra_fields = {})
  default_fields = {
    client: client,
    title: title,
    detail: detail,
    http_status: http_status,
    response: response
  }

  default_fields.merge(extra_fields)
end

#to_sObject


69
70
71
# File 'lib/errors.rb', line 69

def to_s
  to_h.to_s
end