Class: Aptible::Resource::Errors

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#full_messagesObject

rubocop:disable DuplicateMethods



5
6
7
# File 'lib/aptible/resource/errors.rb', line 5

def full_messages
  @full_messages
end

#messagesObject

rubocop:disable DuplicateMethods



5
6
7
# File 'lib/aptible/resource/errors.rb', line 5

def messages
  @messages
end

#status_codeObject

rubocop:disable DuplicateMethods



5
6
7
# File 'lib/aptible/resource/errors.rb', line 5

def status_code
  @status_code
end

Class Method Details

.from_exception(exception) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/aptible/resource/errors.rb', line 7

def self.from_exception(exception)
  new.tap do |errors|
    response_json = JSON.parse(exception.response.body)
    errors.messages = { base: response_json['message'] }
    errors.full_messages = [response_json['message']]
    errors.status_code = exception.response.status
  end
end

Instance Method Details

#any?Boolean

Returns:



24
25
26
# File 'lib/aptible/resource/errors.rb', line 24

def any?
  full_messages.any?
end