Exception: ApiEntreprise::Commons::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/api_entreprise/commons/errors.rb

Direct Known Subclasses

ClientError, ServerError, TransportError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, http_status: nil, errors: [], method: nil, url: nil) ⇒ Error

Returns a new instance of Error.



9
10
11
12
13
14
15
# File 'lib/api_entreprise/commons/errors.rb', line 9

def initialize(message = nil, http_status: nil, errors: [], method: nil, url: nil)
  super(message || default_message(http_status, errors))
  @http_status = http_status
  @errors = errors || []
  @method = method
  @url = url
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/api_entreprise/commons/errors.rb', line 7

def errors
  @errors
end

#http_statusObject (readonly)

Returns the value of attribute http_status.



7
8
9
# File 'lib/api_entreprise/commons/errors.rb', line 7

def http_status
  @http_status
end

#methodObject (readonly)

Returns the value of attribute method.



7
8
9
# File 'lib/api_entreprise/commons/errors.rb', line 7

def method
  @method
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/api_entreprise/commons/errors.rb', line 7

def url
  @url
end

Instance Method Details

#first_errorObject



17
18
19
# File 'lib/api_entreprise/commons/errors.rb', line 17

def first_error
  errors.first || {}
end

#first_error_codeObject



21
22
23
# File 'lib/api_entreprise/commons/errors.rb', line 21

def first_error_code
  first_error['code'] || first_error[:code]
end

#first_error_detailObject



29
30
31
# File 'lib/api_entreprise/commons/errors.rb', line 29

def first_error_detail
  first_error['detail'] || first_error[:detail]
end

#first_error_metaObject



37
38
39
# File 'lib/api_entreprise/commons/errors.rb', line 37

def first_error_meta
  first_error['meta'] || first_error[:meta] || {}
end

#first_error_sourceObject



33
34
35
# File 'lib/api_entreprise/commons/errors.rb', line 33

def first_error_source
  first_error['source'] || first_error[:source]
end

#first_error_titleObject



25
26
27
# File 'lib/api_entreprise/commons/errors.rb', line 25

def first_error_title
  first_error['title'] || first_error[:title]
end